Interface element color display method and apparatus

ABSTRACT

This application discloses an interface element color display method and apparatus. The method includes: obtaining a target image included in a to-be-displayed interface; performing color updating processing on the to-be-displayed interface, including: determining a first dominant color of the target image, determining a color type of the target image based on an area-based ratio of the first dominant color in the target image, determining a first auxiliary color based on the color type, and setting the first auxiliary color as a color of a foreground element; and outputting the to-be-displayed interface that has undergone the color updating processing to a display device for displaying.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.17/187,257, filed on Feb. 26, 2021, which is a continuation ofInternational Application No. PCT/CN2019/101937, filed on Aug. 22, 2019.The International Application claims priority to Chinese PatentApplication No. 201810982547.4, filed on Aug. 27, 2018. All of theafore-mentioned patent applications are hereby incorporated by referencein their entireties.

TECHNICAL FIELD

Embodiments of this application relate to the image processing field,and more specifically, to an interface element color display method andan apparatus.

BACKGROUND

Currently, interaction interfaces of a plurality of applications maydisplay images and foreground elements. In a plurality of scenarios, aforeground element is used as a foreground of an image, and theforeground element may be an element such as an icon or a text.

To form a visual association between a foreground element and an image,a color picker in the industry first selects a target color from aplurality of colors in the image according to some user-defined rules,and then automatically uses the target color as a color of theforeground element, to ensure a similarity between a color of the imageand the color of the foreground element, so that a user has moreimmersive experience when the user browses the image and the foregroundelement on an interaction interface.

In the foregoing image color picking method, a great difference mayexist between a hue of the selected target color and a hue of each ofthe plurality of colors in the image. For example, assuming that theselected target color is red, but the plurality of colors in the imageare mainly green and blue, great differences exist between the hue ofthe target color and hues of the plurality of colors in the image. Ifgreat differences exist between the hue of the selected target color andthe hues of the plurality of colors in the image, and the target coloris used as the color of the foreground element, the colors in the imageand the color of the foreground element may conflict greatly, subject topoor color fusion. Consequently, the user cannot have immersiveexperience when browsing the image and the foreground element on theinteraction interface.

SUMMARY

Embodiments of this application provide an interface element colordisplay method and an apparatus, so that good contrast and color fusionexist between a color of a foreground element and a color of a targetimage on an interface.

The embodiments of this application are implemented as follows:

According to a first aspect, an embodiment of this application providesan interface element color display method. The method includes:obtaining a target image included in a to-be-displayed interface, wherethe to-be-displayed interface includes a foreground element and abackground element, the background element is used as a background ofthe foreground element, and the background element includes the targetimage; performing color updating processing on the to-be-displayedinterface, including: determining a first dominant color of the targetimage, determining a color type of the target image based on anarea-based ratio of the first dominant color in the target image,determining a first auxiliary color based on the color type, and settingthe first auxiliary color as a color of the foreground element, wherethe first dominant color is a main color in the target image, and thefirst auxiliary color is a color with a hue close to that of the firstdominant color but with a difference in saturation or brightness; andoutputting the to-be-displayed interface that has undergone the colorupdating processing to a display device for displaying.

In the first aspect, the hue of the first dominant color of the targetimage is close to the hue of the first auxiliary color, and after thefirst auxiliary color is set as the color of the foreground element,there is good color fusion between the first dominant color of thetarget image and the color of the foreground element. In addition,because there is a difference between the first dominant color and thefirst auxiliary color in saturation or brightness, there is also goodcontrast between the first dominant color and the first auxiliary color,and there is good contrast between the first dominant color of thetarget image and the color of the foreground element. Therefore, when auser browses the to-be-displayed interface, the user has strongimmersive experience.

In a possible implementation of the first aspect, the determining afirst auxiliary color based on the color type includes: obtaining adominant color adjustment parameter corresponding to the color type ofthe target image, where the dominant color adjustment parameter includesat least one of brightness and saturation; adjusting the first dominantcolor based on the dominant color adjustment parameter to generate afirst bright auxiliary color and a first dark auxiliary color; anddetermining the first bright auxiliary color or the first dark auxiliarycolor as the first auxiliary color.

In a possible implementation of the first aspect, the obtaining adominant color adjustment parameter corresponding to the color type ofthe target image includes: when the color type of the target image is apolychromatic general type or a monochromatic colorful type, obtaining afirst brightness adjustment value, a second brightness adjustment value,a first saturation adjustment value, and a second saturation adjustmentvalue corresponding to the polychromatic general type or themonochromatic colorful type, where the first brightness adjustment valueand the second brightness adjustment value are separately used to adjustbrightness of the first dominant color, the first saturation adjustmentvalue and the second saturation adjustment value are separately used toadjust saturation of the first dominant color, and the dominant coloradjustment parameter includes the first brightness adjustment value, thesecond brightness adjustment value, the first saturation adjustmentvalue, and the second saturation adjustment value; the polychromaticgeneral type is used to indicate that a ratio of a quantity of pixelscorresponding to the first dominant color in the target image to aquantity of pixels corresponding to the target image is less than afirst threshold, a ratio of a quantity of pixels corresponding to colorshaving a same three-channel red-green-blue value in the target image tothe quantity of pixels corresponding to the target image is less than asecond threshold, and the saturation of the first dominant color isgreater than a third threshold; and the monochromatic colorful type isused to indicate that the ratio of the quantity of pixels correspondingto the first dominant color in the target image to the quantity ofpixels corresponding to the target image is greater than the firstthreshold, and the saturation of the first dominant color is greaterthan 0; or when the color type of the target image is a polychromaticlow saturation type, a polychromatic grayscale type, or a monochromaticachromatic type, obtaining a first brightness adjustment value and asecond brightness adjustment value corresponding to the polychromaticlow saturation type, the polychromatic grayscale type, or themonochromatic achromatic type, where the first brightness adjustmentvalue and the second brightness adjustment value are separately used toadjust brightness of the first dominant color, and the dominant coloradjustment parameter includes the first brightness adjustment value andthe second brightness adjustment value; the polychromatic low saturationtype is used to indicate that a ratio of a quantity of pixelscorresponding to the first dominant color in the target image to aquantity of pixels corresponding to the target image is less than afirst threshold, a ratio of a quantity of pixels corresponding to colorshaving a same three-channel red-green-blue value in the target image tothe quantity of pixels corresponding to the target image is less than asecond threshold, and saturation of the first dominant color is lessthan a third threshold; the polychromatic grayscale type is used toindicate that the ratio of the quantity of pixels corresponding to thefirst dominant color in the target image to the quantity of pixelscorresponding to the target image is less than the first threshold, andthe ratio of the quantity of pixels corresponding to the colors havingthe same three-channel red-green-blue value in the target image to thequantity of pixels corresponding to the target image is greater than thesecond threshold; and the monochromatic achromatic type is used toindicate that the ratio of the quantity of pixels corresponding to thefirst dominant color in the target image to the quantity of pixelscorresponding to the target image is greater than the first threshold,and the saturation of the first dominant color is equal to 0.

In a possible implementation of the first aspect, the adjusting thefirst dominant color based on the dominant color adjustment parameter togenerate a first bright auxiliary color and a first dark auxiliary colorincludes: adjusting the brightness and saturation of the first dominantcolor based on the first brightness adjustment value and the firstsaturation adjustment value to generate the first bright auxiliarycolor, and adjusting the brightness and saturation of the first dominantcolor based on the second brightness adjustment value and the secondsaturation adjustment value to generate the first dark auxiliary color;or adjusting the brightness of the first dominant color based on thefirst brightness adjustment value to generate the first bright auxiliarycolor, and adjusting the brightness of the first dominant color based onthe second brightness adjustment value to generate the first darkauxiliary color.

In a possible implementation of the first aspect, the determining thefirst bright auxiliary color or the first dark auxiliary color as thefirst auxiliary color includes: determining whether a ratio of abrightness differentiation parameter of the first dominant color to abrightness differentiation parameter of the first bright auxiliary coloris greater than a fourth threshold or less than a reciprocal of thefourth threshold; and when the ratio of the brightness differentiationparameter of the first dominant color to the brightness differentiationparameter of the first bright auxiliary color is greater than the fourththreshold or less than the reciprocal of the fourth threshold,determining the first bright auxiliary color as the first auxiliarycolor; or when the ratio of the brightness differentiation parameter ofthe first dominant color to the brightness differentiation parameter ofthe first bright auxiliary color is less than the fourth threshold orgreater than the reciprocal of the fourth threshold, determining thefirst dark auxiliary color as the first auxiliary color.

In a possible implementation of the first aspect, the determining afirst dominant color of the target image includes: obtaining each colorin the target image; sorting each color in the target image in a presetarrangement order to obtain a color queue, where the preset arrangementorder is a pre-generated arrangement order of colors; dividing the colorqueue into a plurality of color groups based on a preset grouping methodand a quantity of pixels of each color in the target image, where eachof the plurality of color groups includes at least one color;determining, in the plurality of color groups, a target color grouphaving a largest quantity of pixels; and generating the first dominantcolor based on all colors in the target color group.

In a possible implementation of the first aspect, the generating thefirst dominant color based on all colors in the target color groupincludes: obtaining a three-channel red-green-blue value of each colorin the target color group, where the three-channel red-green-blue valueincludes a red channel value, a green channel value, and a blue channelvalue; calculating a target red channel value based on the red channelvalue of each color in the target color group and a ratio of a quantityof pixels of each color in the target color group to a quantity ofpixels in the target color group; calculating a target green channelvalue based on the green channel value of each color in the target colorgroup and the ratio of the quantity of pixels of each color in thetarget color group to the quantity of pixels in the target color group;calculating a target blue channel value based on the blue channel valueof each color in the target color group and the ratio of the quantity ofpixels of each color in the target color group to the quantity of pixelsin the target color group; and combining the target red channel value,the target green channel value, and the target blue channel value into atarget three-channel red-green-blue value to obtain the first dominantcolor.

In a possible implementation of the first aspect, after the determininga color type of the target image based on an area-based ratio of thefirst dominant color in the target image, the method further includes:when the color type of the target image is a polychromatic type,determining, in the plurality of color groups, a specified color grouphaving a second largest quantity of pixels, and generating a seconddominant color based on all colors in the specified color group, wherethe polychromatic type is used to indicate that a ratio of a quantity ofpixels corresponding to the first dominant color in the target image toa quantity of pixels corresponding to the target image is less than afirst threshold; or when the color type of the target image is amonochromatic colorful type, obtaining a second dominant coloradjustment value corresponding to the monochromatic colorful type, andconfiguring the hue of the first dominant color based on the seconddominant color adjustment value to generate a second dominant color,where the monochromatic colorful type is used to indicate that a ratioof a quantity of pixels corresponding to the first dominant color in thetarget image to a quantity of pixels corresponding to the target imageis greater than a first threshold, and saturation of the first dominantcolor is greater than 0; or when the color type of the target image is amonochromatic achromatic type, obtaining a second dominant coloradjustment value corresponding to the monochromatic achromatic type, andconfiguring brightness of the first dominant color based on the seconddominant color adjustment value to generate a second dominant color,where the monochromatic achromatic type is used to indicate that a ratioof a quantity of pixels corresponding to the first dominant color in thetarget image to a quantity of pixels corresponding to the target imageis greater than a first threshold, and saturation of the first dominantcolor is equal to 0.

In a possible implementation of the first aspect, after the seconddominant color is generated, the method further includes: obtaining adominant color adjustment parameter corresponding to the color type ofthe target image, where the dominant color adjustment parameter includesat least one of brightness and saturation; adjusting the second dominantcolor based on the dominant color adjustment parameter to generate asecond bright auxiliary color and a second dark auxiliary color;determining the second bright auxiliary color or the second darkauxiliary color as a second auxiliary color, where the second auxiliarycolor is a color with a hue close to that of the second dominant colorbut with a difference in saturation or brightness; when an instructionfor setting the second auxiliary color as the color of the foregroundelement is received, setting the second auxiliary color as the color ofthe foreground element; and setting the second dominant color as a colorof a background layer, where the background layer is a layer withunchanged transparency or a layer with gradient transparency, thebackground element further includes the background layer, and thebackground layer is located between the target image and the foregroundelement.

In a possible implementation of the first aspect, the background elementfurther includes a background layer, the background layer is locatedbetween the target image and the foreground element, and the performingcolor updating processing on the target image further includes: settingthe first dominant color as a color of the background layer, where thebackground layer is a layer with unchanged transparency or a layer withgradient transparency.

In a possible implementation of the first aspect, after the determininga first dominant color of the target image, and before the outputtingthe to-be-displayed interface that has undergone the color updatingprocessing to a display device for displaying, the method furtherincludes: obtaining an image region by extending one side or a pluralityof sides of the target image, where the image region includes the firstdominant color; and using the image region and the target image as anupdated target image.

According to a second aspect, an embodiment of this application providesa terminal. The terminal includes: an obtaining module, configured toobtain a target image included in a to-be-displayed interface, where theto-be-displayed interface includes a foreground element and a backgroundelement, the background element is used as a background of theforeground element, and the background element includes the targetimage; an updating module, configured to perform color updatingprocessing on the to-be-displayed interface, including: determining afirst dominant color of the target image, determining a color type ofthe target image based on an area-based ratio of the first dominantcolor in the target image, determining a first auxiliary color based onthe color type, and setting the first auxiliary color as a color of theforeground element, where the first dominant color is a main color inthe target image, and the first auxiliary color is a color with a hueclose to that of the first dominant color but with a difference insaturation or brightness; and a display output module, configured tooutput the to-be-displayed interface that has undergone the colorupdating processing to a display device for displaying.

In a possible implementation of the second aspect, the updating moduleis specifically configured to: obtain a dominant color adjustmentparameter corresponding to the color type of the target image, where thedominant color adjustment parameter includes at least one of brightnessand saturation; adjust the first dominant color based on the dominantcolor adjustment parameter to generate a first bright auxiliary colorand a first dark auxiliary color; and determine the first brightauxiliary color or the first dark auxiliary color as the first auxiliarycolor.

In a possible implementation of the second aspect, the updating moduleis specifically configured to: when the color type of the target imageis a polychromatic general type or a monochromatic colorful type, obtaina first brightness adjustment value, a second brightness adjustmentvalue, a first saturation adjustment value, and a second saturationadjustment value corresponding to the polychromatic general type or themonochromatic colorful type, where the first brightness adjustment valueand the second brightness adjustment value are separately used to adjustbrightness of the first dominant color, the first saturation adjustmentvalue and the second saturation adjustment value are separately used toadjust saturation of the first dominant color, and the dominant coloradjustment parameter includes the first brightness adjustment value, thesecond brightness adjustment value, the first saturation adjustmentvalue, and the second saturation adjustment value; the polychromaticgeneral type is used to indicate that a ratio of a quantity of pixelscorresponding to the first dominant color in the target image to aquantity of pixels corresponding to the target image is less than afirst threshold, a ratio of a quantity of pixels corresponding to colorshaving a same three-channel red-green-blue value in the target image tothe quantity of pixels corresponding to the target image is less than asecond threshold, and the saturation of the first dominant color isgreater than a third threshold; and the monochromatic colorful type isused to indicate that the ratio of the quantity of pixels correspondingto the first dominant color in the target image to the quantity ofpixels corresponding to the target image is greater than the firstthreshold, and the saturation of the first dominant color is greaterthan 0; or the updating module is specifically configured to: when thecolor type of the target image is a polychromatic low saturation type, apolychromatic grayscale type, or a monochromatic achromatic type, obtaina first brightness adjustment value and a second brightness adjustmentvalue corresponding to the polychromatic low saturation type, thepolychromatic grayscale type, or the monochromatic achromatic type,where the first brightness adjustment value and the second brightnessadjustment value are separately used to adjust brightness of the firstdominant color, and the dominant color adjustment parameter includes thefirst brightness adjustment value and the second brightness adjustmentvalue; the polychromatic low saturation type is used to indicate that aratio of a quantity of pixels corresponding to the first dominant colorin the target image to a quantity of pixels corresponding to the targetimage is less than a first threshold, a ratio of a quantity of pixelscorresponding to colors having a same three-channel red-green-blue valuein the target image to the quantity of pixels corresponding to thetarget image is less than a second threshold, and saturation of thefirst dominant color is less than a third threshold; the polychromaticgrayscale type is used to indicate that the ratio of the quantity ofpixels corresponding to the first dominant color in the target image tothe quantity of pixels corresponding to the target image is less thanthe first threshold, and the ratio of the quantity of pixelscorresponding to the colors having the same three-channel red-green-bluevalue in the target image to the quantity of pixels corresponding to thetarget image is greater than the second threshold; and the monochromaticachromatic type is used to indicate that the ratio of the quantity ofpixels corresponding to the first dominant color in the target image tothe quantity of pixels corresponding to the target image is greater thanthe first threshold, and the saturation of the first dominant color isequal to 0.

In a possible implementation of the second aspect, the updating moduleis specifically configured to adjust the brightness and saturation ofthe first dominant color based on the first brightness adjustment valueand the first saturation adjustment value to generate the first brightauxiliary color, and adjust the brightness and saturation of the firstdominant color based on the second brightness adjustment value and thesecond saturation adjustment value to generate the first dark auxiliarycolor; or the updating module is specifically configured to adjust thebrightness of the first dominant color based on the first brightnessadjustment value to generate the first bright auxiliary color, andadjust the brightness of the first dominant color based on the secondbrightness adjustment value to generate the first dark auxiliary color.

In a possible implementation of the second aspect, the updating moduleis specifically configured to: determine whether a ratio of a brightnessdifferentiation parameter of the first dominant color to a brightnessdifferentiation parameter of the first bright auxiliary color is greaterthan a fourth threshold or less than a reciprocal of the fourththreshold; and when the ratio of the brightness differentiationparameter of the first dominant color to the brightness differentiationparameter of the first bright auxiliary color is greater than the fourththreshold or less than the reciprocal of the fourth threshold, determinethe first bright auxiliary color as the first auxiliary color; or whenthe ratio of the brightness differentiation parameter of the firstdominant color to the brightness differentiation parameter of the firstbright auxiliary color is less than the fourth threshold or greater thanthe reciprocal of the fourth threshold, determine the first darkauxiliary color as the first auxiliary color, where the brightnessdifferentiation parameter of the first bright auxiliary color is greaterthan a brightness differentiation parameter of the first dark auxiliarycolor, the brightness differentiation parameter of the first dominantcolor is obtained through calculation based on a three-channelred-green-blue value of the first dominant color, the brightnessdifferentiation parameter of the first bright auxiliary color isobtained through calculation based on a three-channel red-green-bluevalue of the first bright auxiliary color, and the brightnessdifferentiation parameter of the first dark auxiliary color is obtainedthrough calculation based on a three-channel red-green-blue value of thefirst dark auxiliary color.

In a possible implementation of the second aspect, the updating moduleis specifically configured to: obtain each color in the target image;sort each color in the target image in a preset arrangement order toobtain a color queue, where the preset arrangement order is apre-generated arrangement order of colors; divide the color queue into aplurality of color groups based on a preset grouping method and aquantity of pixels of each color in the target image, where each of theplurality of color groups includes at least one color; determine, in theplurality of color groups, a target color group having a largestquantity of pixels; and generate the first dominant color based on allcolors in the target color group.

In a possible implementation of the second aspect, the updating moduleis specifically configured to: obtain a three-channel red-green-bluevalue of each color in the target color group, where the three-channelred-green-blue value includes a red channel value, a green channelvalue, and a blue channel value; calculate a target red channel valuebased on the red channel value of each color in the target color groupand a ratio of a quantity of pixels of each color in the target colorgroup to a quantity of pixels in the target color group; calculate atarget green channel value based on the green channel value of eachcolor in the target color group and the ratio of the quantity of pixelsof each color in the target color group to the quantity of pixels in thetarget color group; calculate a target blue channel value based on theblue channel value of each color in the target color group and the ratioof the quantity of pixels of each color in the target color group to thequantity of pixels in the target color group; and combine the target redchannel value, the target green channel value, and the target bluechannel value into a target three-channel red-green-blue value to obtainthe first dominant color.

In a possible implementation of the second aspect, the updating moduleis further configured to: when the color type of the target image is apolychromatic type, determine, in the plurality of color groups, aspecified color group having a second largest quantity of pixels, andgenerate a second dominant color based on all colors in the specifiedcolor group, where the polychromatic type is used to indicate that aratio of a quantity of pixels corresponding to the first dominant colorin the target image to a quantity of pixels corresponding to the targetimage is less than a first threshold; or the updating module is furtherconfigured to: when the color type of the target image is amonochromatic colorful type, obtain a second dominant color adjustmentvalue corresponding to the monochromatic colorful type, and configurethe hue of the first dominant color based on the second dominant coloradjustment value to generate a second dominant color, where themonochromatic colorful type is used to indicate that a ratio of aquantity of pixels corresponding to the first dominant color in thetarget image to a quantity of pixels corresponding to the target imageis greater than a first threshold, and saturation of the first dominantcolor is greater than 0; or the updating module is further configuredto: when the color type of the target image is a monochromaticachromatic type, obtain a second dominant color adjustment valuecorresponding to the monochromatic achromatic type, and configurebrightness of the first dominant color based on the second dominantcolor adjustment value to generate a second dominant color, where themonochromatic achromatic type is used to indicate that a ratio of aquantity of pixels corresponding to the first dominant color in thetarget image to a quantity of pixels corresponding to the target imageis greater than a first threshold, and saturation of the first dominantcolor is equal to 0.

In a possible implementation of the second aspect, the updating moduleis further configured to: obtain a dominant color adjustment parametercorresponding to the color type of the target image, where the dominantcolor adjustment parameter includes at least one of brightness andsaturation; adjust the second dominant color based on the dominant coloradjustment parameter to generate a second bright auxiliary color and asecond dark auxiliary color; determine the second bright auxiliary coloror the second dark auxiliary color as a second auxiliary color, wherethe second auxiliary color is a color with a hue close to that of thesecond dominant color but with a difference in saturation or brightness;when an instruction for setting the second auxiliary color as the colorof the foreground element is received, set the second auxiliary color asthe color of the foreground element; and set the second dominant coloras a color of a background layer, where the background layer is a layerwith unchanged transparency or a layer with gradient transparency, thebackground element further includes the background layer, and thebackground layer is located between the target image and the foregroundelement.

In a possible implementation of the second aspect, the updating moduleis further configured to set the first dominant color as a color of abackground layer, where the background layer is a layer with unchangedtransparency or a layer with gradient transparency.

In a possible implementation of the second aspect, the updating moduleis further configured to: obtain an image region by extending one sideor a plurality of sides of the target image, where the image regionincludes the first dominant color; and use the image region and thetarget image as an updated target image.

According to a third aspect, this application discloses a terminal,including one or more processors and a memory, where the one or moreprocessors are configured to read software code stored in the memory andperform the method according to any one of the first aspect and theimplementations of the first aspect.

According to a fourth aspect, this application discloses acomputer-readable storage medium, where the computer-readable storagemedium stores software code, and when being read by one or moreprocessors, the software code is code capable of performing the methodaccording to the first aspect and the implementations of the firstaspect.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of a terminal interface according to anembodiment of this application;

FIG. 2 is a flowchart of an interface element color display methodaccording to an embodiment of this application;

FIG. 3 is a schematic diagram of a terminal interface according to anembodiment of this application;

FIG. 4 is a schematic diagram of an image in a region A in FIG. 3;

FIG. 5 is a schematic diagram of an image in a region B in FIG. 3;

FIG. 6 is a flowchart of another interface element color display methodaccording to an embodiment of this application;

FIG. 7 is a schematic diagram of arrangement order of each color and aquantity of pixels of each color in a target image;

FIG. 8 is a schematic diagram of first grouping based on FIG. 7;

FIG. 9 is a schematic diagram of final grouping based on FIG. 7;

FIG. 10 is a schematic diagram of classification of color typesaccording to an embodiment of this application;

FIG. 11 is a flowchart of still another interface element color displaymethod according to an embodiment of this application;

FIG. 12 is a flowchart of still another interface element color displaymethod according to an embodiment of this application;

FIG. 13 is a flowchart of still another interface element color displaymethod according to an embodiment of this application;

FIG. 14 is a schematic diagram of a terminal according to an embodimentof this application; and

FIG. 15 is a schematic diagram of a terminal according to an embodimentof this application.

DESCRIPTION OF EMBODIMENTS

FIG. 1 is a schematic diagram of a terminal interface according to anembodiment of this application. In FIG. 1, a touchscreen 2 of a terminal1 is currently displaying a gallery interface 3. The gallery interface 3includes a text 31, an icon 32, and an image 33. The image 33 is used asa background of the text 31 and the icon 32. The text 31 and the icon 32are used as a foreground of the image 33. The text 31 and the icon 32belong to a foreground element. The image 33 belongs to a backgroundelement. The background element is used as a background of theforeground element.

In the embodiment shown in FIG. 1, the text 31 on the gallery interface3 includes “Share”, “Download”, “Delete”, “Edit”, and “More”. The icon32 on the gallery interface 3 includes a “Share” function button, a“Download” function button, a “Delete” function button, an “Edit”function button, and a “More” function button. The image 33 on thegallery interface 3 is a plant.

In the embodiment shown in FIG. 1, after the terminal 1 receives aninstruction for displaying the image 33, the terminal 1 may firstgenerate a first dominant color based on colors in the image 33,determine a color type of the image 33 based on an area-based ratio ofthe first dominant color in the image 33, and determine a firstauxiliary color based on the color type; then set the first auxiliarycolor as a color of the text 31 and a color of the icon 32 on thegallery interface 3, that is, set the first auxiliary color as a colorof the foreground element of the gallery interface 3; and finallydisplay the gallery interface 3 after the color change. In the processin which the terminal 1 generates the first auxiliary color based on thefirst dominant color in the image 33, the selected first dominant colormay be a main color in the image 33, and the generated first auxiliarycolor may be a color with a hue close to that of the first dominantcolor but with a difference in saturation or brightness. Being close inhue means that an absolute value of hue difference between the firstdominant color and the first auxiliary color is less than a threshold.For example, the threshold may be 30 degrees.

In the embodiment shown in FIG. 1, because the hue of the first dominantcolor is close to the hue of the first auxiliary color, there is goodcolor fusion between the color of the text 31 and the color of the icon32 and the color of the image 33, that is, there is good color fusionbetween the first dominant color and the first auxiliary color. Inaddition, because there is a difference between the first dominant colorand the first auxiliary color in saturation or brightness, there is goodcontrast between the color of the text 31 and the color of the icon 32and the color of the image 33, that is, there is also good contrastbetween the first dominant color and the first auxiliary color.Therefore, when a user browses the text 31, the icon 32, and the image33 on the gallery interface 3, the user has strong immersive experience.

Certainly, the interface in this embodiment of this application is notlimited to the gallery interface of the terminal shown in FIG. 1, andmay also be another type of interface on the terminal. For example, theinterface of the terminal may also be a lock screen interface of theterminal or a lock screen interface of an application. For example,alternatively, the interface of the terminal may be an interface of amusic player on the terminal. For example, alternatively, the interfaceof the terminal may be a notification bar interface of the terminal. Insummary, a scenario in which an interface element color display methodprovided in an embodiment of this application is used is not limited tothe foregoing interfaces of the terminal. The interface element colordisplay method provided in the embodiment of this application may beused for various interfaces on the terminal as long as the interfaces onthe terminal include foreground elements and background elements.

The terminal 1 shown in FIG. 1 may be a device such as a desktopcomputer, a notebook computer, a palmtop computer, or a smartphone. Thedevice generally includes one or more processors, a memory, and adisplay device. The one or more processors are configured to read codestored in the memory to execute a corresponding program. When there isone processor, the processor may be a CPU. When there are a plurality ofprocessors, the processors may include one CPU and further include oneor more image processors (for example, GPUs). One or more of theprocessors may be packaged on one chip, or the processors may beindependently packaged on a plurality of chips. In this application, thedisplay device is a hardware device used for displaying, for example,various devices that may be used for displaying, such as a displayscreen of the terminal or a display of a personal computer. The deviceis connected to the processor by using various interfaces. After theprocessor completes processing of data (for example, a to-be-displayedinterface is obtained), the data is sent through an interface to thedisplay device for displaying.

FIG. 1 illustrates how to apply an interface element color displaymethod provided in an embodiment of this application to a specificterminal interface. The following describes in detail interface elementcolor display methods provided in embodiments of this application. Itmay be understood that these methods may be implemented by one or moreprocessors.

FIG. 2 is a flowchart of an interface element color display methodaccording to an embodiment of this application. The method shown in FIG.2 may be used to achieve good contrast and color fusion between a colorof a foreground element and a color of a target image on a terminalinterface. The method shown in FIG. 2 may be applied to a terminal. Themethod shown in FIG. 2 includes the following steps.

Step S11: Obtain a target image included in a to-be-displayed interface.

To-be-displayed interfaces of a terminal may be different interfaces indifferent technical scenarios.

For example, after the terminal is powered on, and before the terminalenters a lock screen interface, the terminal may first obtain a targetimage included in the lock screen interface.

For another example, with reference to FIG. 1, assuming that the userenters an instruction for viewing the image 33 to the terminal 1, afterthe terminal 1 receives the instruction for viewing the image 33, andbefore the touchscreen 2 displays the image 33 of the gallery interface3, the terminal 1 may first obtain the image 33 of the gallery interface3.

In step S11, the to-be-displayed interface includes a foreground elementand a background element. The background element is an element used as abackground of the foreground element. The background element includesthe target image.

For example, with reference to FIG. 1, the to-be-displayed interface maybe the gallery interface 3 in FIG. 1, the target image may be the image33 in FIG. 1, the foreground element may be the text 31 and the icon 32in FIG. 1, and the background element includes the image 33 in FIG. 1.

In step S11, the target image included in the to-be-displayed interfacemay be obtained in a plurality of manners. The following describesseveral specific manners.

First manner: Obtain an original image included in the to-be-displayedinterface, and determine the original image as the target image.

In this first manner, the original image is a complete image on theto-be-displayed interface, and the target image is a complete image onthe to-be-displayed interface.

For example, with reference to FIG. 1, the image 33 included in thegallery interface 3 may be understood as the original image included inthe to-be-displayed interface, and the target image is the image 33included in the gallery interface 3.

Second manner: Obtain an original image included in the to-be-displayedinterface, determine a preset target region on the to-be-displayedinterface, and crop the target image in the target region from theoriginal image.

In the second manner, the original image is a complete image on theto-be-displayed interface, the preset target region is a preset regionon the to-be-displayed interface, and the target image is an image ofthe original image that is displayed in the target region.

For example, with reference to FIG. 3 and FIG. 4, FIG. 3 is a schematicdiagram of a terminal interface according to an embodiment of thisapplication, and FIG. 4 is a schematic diagram of an image in a region Ain FIG. 3. In FIG. 3 and FIG. 4, assuming that the preset target regionis the region A, the target image in the region A may be obtained bycropping the image in the region A from the image 33, as shown in FIG.4.

Third manner: Obtain an original image included in the to-be-displayedinterface, determine a target region in which the foreground element islocated on the to-be-displayed interface, and crop the target image inthe target region from the original image.

In the third manner, the original image is a complete image on theto-be-displayed interface, the target region is the region in which theforeground element is located on the to-be-displayed interface, and thetarget image is an image of the original image that is displayed in thetarget region.

For example, with reference to FIG. 3 and FIG. 5, FIG. 5 is a schematicdiagram of an image in a region B in FIG. 3. In FIG. 3 and FIG. 5, thetext 31 and the icon 32 on the gallery interface 3 are both located inthe region B, that is, the target region in which the foreground elementis located on the to-be-displayed interface is the region B. After theimage in the region B is cropped from the image 33, the target image inthe region B may be obtained, as shown in FIG. 5.

Step S12: Perform color updating processing on the to-be-displayedinterface.

After the terminal obtains the target image included in theto-be-displayed interface, the terminal needs to perform color updatingprocessing on the to-be-displayed interface. Performing color updatingprocessing on the to-be-displayed interface by the terminal may includeS121, step S122, and step S123.

Step S121: Determine a first dominant color of the target image.

The terminal may determine the first dominant color of the target imagein a plurality of manners. For example, the terminal may generate adominant color based on a main color in the target image. For anotherexample, the terminal may select a main color from the target image.Regardless of which manner is used to generate the dominant color of thetarget image, the dominant color is the main color in the target image.

Step S122: Determine a color type of the target image based on anarea-based ratio of the first dominant color in the target image, anddetermine a first auxiliary color based on the color type.

The ratio of the area occupied by the first dominant color in the targetimage is a ratio of a quantity of pixels of the first dominant color inthe target image to a quantity of pixels in the target image. Forexample, assuming that the quantity of pixels of the first dominantcolor in the target image is 500 and that the quantity of pixels in thetarget image 1000, the ratio of the area occupied by the first dominantcolor in the target image is 500±1000=50%.

There are a plurality of color types. The plurality of color types aredescribed in detail in subsequent embodiments.

The terminal may determine the first auxiliary color based on the colortype in a plurality of manners. Regardless of which manner is used,compliance with the following rule is required: A hue of the firstauxiliary color is close to a hue of the first dominant color, and thereis a difference between the first auxiliary color and the first dominantcolor in saturation or brightness.

Step S123: Set the first auxiliary color as a color of the foregroundelement.

After the terminal determines the first auxiliary color based on thecolor type, the terminal needs to set the first auxiliary color as thecolor of the foreground element.

Step S13: Output the to-be-displayed interface that has undergone thecolor updating processing to a display device for displaying.

For example, a processor includes a CPU, and displaying may be performedby using an interface between the CPU and the display device.

In the embodiment shown in FIG. 2, the hue of the first dominant colorof the target image is close to the hue of the first auxiliary color,and after the first auxiliary color is set as the color of theforeground element, there is good color fusion between the firstdominant color of the target image and the color of the foregroundelement. In addition, because there is a difference between the firstdominant color and the first auxiliary color in saturation orbrightness, there is also good contrast between the first dominant colorand the first auxiliary color, and there is good contrast between thefirst dominant color of the target image and the color of the foregroundelement. Therefore, when the user browses the to-be-displayed interface,the user has strong immersive experience.

In the embodiment shown in FIG. 2, after step S123, that is, after thefirst auxiliary color is set as the color of the foreground element, themethod may further include the following step: setting the firstdominant color as a color of a background layer.

The background element further includes the background layer. Thebackground layer is located between the target image and the foregroundelement. The background layer is a layer with unchanged transparency orgradient transparency.

To better highlight the foreground element in the target image, thefirst dominant color may be set as the color of the background layer.Because the background layer is located between the target image and theforeground element, the background layer may be used to set off theforeground element and further highlight the foreground element.Moreover, the hue of the first dominant color is close to the hue of thefirst auxiliary color, and there is good color fusion between the colorof the background layer and the color of the foreground element. Inaddition, because there is a difference between the first dominant colorand the first auxiliary color in saturation or brightness, there is alsogood contrast between the first dominant color and the first auxiliarycolor, and there is good contrast between the color of the backgroundlayer and the color of the foreground element. Therefore, when the userbrowses the to-be-displayed interface, the user has strong immersiveexperience.

In the embodiment shown in FIG. 2, after step S121, that is, afterdetermining the first dominant color of the target image, the method mayfurther include the following step: obtaining an image region byextending one side or a plurality of sides of the target image, wherethe image region includes the first dominant color; and using the imageregion and the target image as an updated target image.

After the terminal determines the first dominant color of the targetimage, the terminal may further obtain an image region by extending oneside or a plurality of sides of the target image, and may set theforeground element in this image region. Therefore, the foregroundelement can be prevented from being located in the target image andblocking the target image, and the user can see the target image notblocked by the foreground element. In addition, because the color of theforeground element is the first auxiliary color, using the firstdominant color as a color of the image region can ensure that there isgood contrast between the color of the image region and the color of theforeground element. Therefore, when the user browses the to-be-displayedinterface, the user has strong immersive experience.

FIG. 6 is a flowchart of another interface element color display methodaccording to an embodiment of this application. The embodiment shown inFIG. 6 is a specific implementation of step S121 in FIG. 2, that is, theembodiment shown in FIG. 6 is how to determine a first dominant color ofa target image. The method shown in FIG. 6 includes the following steps.

Step S21: Obtain each color in a target image.

After a terminal obtains a target image included in a to-be-displayedinterface, the terminal needs to first obtain each color in the targetimage, so that the terminal obtains a main color in the target image byusing each color in the target image and generates a first dominantcolor by using the main color in the target image. The main color in thetarget image may be one color or may be a plurality of colors.

For example, with reference to FIG. 1, it is assumed that the image 33included in the gallery interface 3 has 20 colors. After the terminal 1obtains the image 33 included in the gallery interface 3, the terminalneeds to obtain the 20 colors in the image 33.

Step S22: Divide the colors in the target image into a plurality ofcolor groups, where each of the plurality of color groups includes atleast one color.

If a color group includes at least two colors, all the colors in thecolor group are similar colors.

The colors in the target image may be divided into a plurality of colorgroups in a plurality of manners. The following describes a specificimplementation.

Dividing the colors in the target image into a plurality of color groupsmay be implemented in the following manner: first, sorting each color inthe target image in a preset arrangement order to obtain a color queue,where the preset arrangement order is a pre-generated arrangement orderof colors; and dividing the color queue into a plurality of color groupsbased on a preset grouping method and a quantity of pixels of each colorin the target image.

The following uses an example to describe how to divide the colors inthe target image into a plurality of color groups.

With reference to FIG. 7, FIG. 8, and FIG. 9, FIG. 7 is a schematicdiagram of arrangement order of each color and the quantity of pixels ofeach color in the target image. Each letter (A to T) in an x-axis inFIG. 7 represents one color, and a number in a y-axis in FIG. 7represents the quantity of pixels of each color. FIG. 8 is a schematicdiagram of first grouping based on FIG. 7. FIG. 9 is a schematic diagramof final grouping based on FIG. 7.

For example, assuming that a size of the target image is 27 pixels×4pixels, a quantity of pixels in the target image is 108, and the targetimage has 20 colors.

First, after the terminal obtains the 20 colors in the target image, theterminal may arrange the 20 colors in the target image in ascendingorder of angles of hues to obtain a color queue. The ascending order ofthe angles of the hues is 0 degrees to 359 degrees. The arrangementorder of the 20 colors in the color queue is an arrangement order of 20colors in the x-axis in FIG. 7.

Then the terminal needs to annotate the 20 colors in the color queuewith quantities of pixels corresponding to the colors. To be specific,the color A has 3 pixels, the color B has 6 pixels, . . . , and thecolor T has 6 pixels.

Next, a binary search method is used to divide the color queue into aplurality of color groups. Specifically, starting from an origin on thex-axis in FIG. 7, the quantity of pixels of each color on the x-axis isaccumulated until the accumulated quantity of pixels is greater thanhalf the quantity of pixels in the target image; and by using acurrently accumulated color as a dividing point, the 20 colors on thex-axis in FIG. 7 are divided into a first color group and a second colorgroup. In FIG. 7, the quantity of pixels of each color on the x-axis isaccumulated. When accumulation is performed from a quantity of pixels ofthe color A to a quantity of pixels of the color K, the accumulatedquantity of pixels is 3+6+5+4+7+8+7+6+2+2+5=55, greater than 54. To bespecific, the accumulated quantity of pixels is 55, greater than halfthe quantity 108 of pixels in the target image, that is, 54. In thiscase, the color A to the color K on the x-axis in FIG. 7 are used as thefirst color group, and the color L to the color T on the x-axis in FIG.7 are used as the second color group. In this case, refer to an effectshown in FIG. 8. As shown in FIG. 8, the color queue is divided into twocolor groups, and the color groups are the first color group and thesecond color group.

If it is predetermined that the color queue is divided into a presetquantity of color groups, the binary search method may be used tocontinue to divide each color group, until a quantity of color groupsresulting from division is the preset quantity.

For example, assuming that it is predetermined that the color queue isdivided into eight color groups, the binary search method may be used tocontinue to divide the first color group into a third color group and afourth color group and the binary search method is used to continue todivide the second color group into a fifth color group and a sixth colorgroup. In this case, there are four color groups in total: the thirdcolor group, the fourth color group, the fifth color group, and thesixth color group. To obtain eight color groups, the binary searchmethod still needs to be used to further divide each color group once.To be specific, the binary search method is used to divide the thirdcolor group into a seventh color group and an eighth color group, thebinary search method is used to divide the fourth color group into aninth color group and a tenth color group, the binary search method isused to divide the fifth color group into an eleventh color group and atwelfth color group, and the binary search method is used to divide thesixth color group into a thirteenth color group and a fourteenth colorgroup.

With reference to FIG. 9, after the color queue is divided by using thebinary search method for three times, eight color groups are finallyobtained. The eight color groups include the seventh color group, theeighth color group, the ninth color group, the tenth color group, theeleventh color group, the twelfth color group, the thirteenth colorgroup, and the fourteenth color group. The seventh color group includesthe color A, the color B, the color C, and the color D. The eighth colorgroup includes the color E and the color F. The ninth color groupincludes the color G and the color H. The tenth color group includes thecolor I, the color J, and the color K. The eleventh color group includesthe color L, the color M, and the color N. The twelfth color groupincludes the color O and the color P. The thirteenth color groupincludes the color Q and the color R. The fourteenth color groupincludes the color S and the color T.

In the embodiments shown in FIG. 7, FIG. 8, and FIG. 9, the terminaldivides the 20 colors in the target image into eight color groups.Certainly, the preset arrangement order is not limited to the ascendingorder of the angles of the hues that is already provided in thisembodiment of this application. Alternatively, another arrangement ordermay be used. For example, the arrangement order may be descending orderof the angles of the hues. In addition, the preset grouping method isnot limited to the binary search method already provided in thisembodiment of this application. Alternatively, another grouping methodmay be used.

Step S23: Determine, in the plurality of color groups, a target colorgroup having a largest quantity of pixels.

After the terminal divides the colors in the target image into theplurality of color groups, each color group has one or more colors, anda quantity of pixels of each color in each color group can be obtained.Therefore, the terminal can determine, in the plurality of color groups,the target color group having the largest quantity of pixels.

For example, with reference to FIG. 9, after the color queue is dividedby using the binary search method for three times, eight color groupsare finally obtained. The eight color groups include the seventh colorgroup, the eighth color group, the ninth color group, the tenth colorgroup, the eleventh color group, the twelfth color group, the thirteenthcolor group, and the fourteenth color group. As can be learned from FIG.9, the seventh color group has 18 pixels, the eighth color group has 15pixels, the ninth color group has 13 pixels, the tenth color group has 9pixels, the eleventh color group has 19 pixels, the twelfth color grouphas 11 pixels, the thirteenth color group has 12 pixels, and thefourteenth color group has 11 pixels. It can be learned throughcomparison that in the eight color groups, the eleventh color group isthe color group having the largest quantity of pixels, that is, theeleventh color group is the target color group.

Step S24: Generate the first dominant color based on all colors in thetarget color group.

The first dominant color may be generated based on all the colors in thetarget color group in a plurality of manners. The following describes aspecific implementation:

first, obtaining a three-channel red-green-blue value of each color inthe target color group, where the three-channel red-green-blue valueincludes a red channel value, a green channel value, and a blue channelvalue; then calculating a target red channel value based on the redchannel value of each color in the target color group and a ratio of aquantity of pixels of each color in the target color group to a quantityof pixels in the target color group; calculating a target green channelvalue based on the green channel value of each color in the target colorgroup and the ratio of the quantity of pixels of each color in thetarget color group to the quantity of pixels in the target color group;calculating a target blue channel value based on the blue channel valueof each color in the target color group and the ratio of the quantity ofpixels of each color in the target color group to the quantity of pixelsin the target color group; and finally combining the target red channelvalue, the target green channel value, and the target blue channel valueinto a target three-channel red-green-blue value to obtain the firstdominant color.

For example, with reference to FIG. 9, the eleventh color group is thetarget color group, and the eleventh color group includes the color L,the color M, and the color N, where a quantity of pixels of the color Lis 8, a quantity of pixels of the color M is 5, and a quantity of pixelsof the color N is 6; therefore, the eleventh color group has 19 pixels.A red channel value of the color L, a red channel value of the color M,and a red channel value of the color N are respectively L (R), M (R),and N (R). A green channel value of the color L, a green channel valueof the color M, and a green channel value of the color N arerespectively L (G), M (G), and N (G). A blue channel value of the colorL, a blue channel value of the color M, and a blue channel value of thecolor N are respectively L (B), M (B), and N (B).

Target red channel value=L (R)×8/(8+5+6)+M (R)×5/(8+5+6)+N(R)×6/(8+5+6). Target green channel value=L (G)×8/(8+5+6)+M(G)×5/(8+5+6)+N (G)×6/(8+5+6). Target blue channel value=L(B)×8/(8+5+6)+M (B)×5/(8+5+6)+N(B)×6/(8+5+6).

8/(8+5+6) is a ratio of the quantity of pixels of the color L to thequantity of pixels in the eleventh color group, that is, a ratio of thequantity of pixels of the color L to the quantity of pixels in thetarget color group. 5/(8+5+6) is a ratio of the quantity of pixels ofthe color M to the quantity of pixels in the eleventh color group, thatis, a ratio of the quantity of pixels of the color M to the quantity ofpixels in the target color group. 6/(8+5+6) is a ratio of the quantityof pixels of the color N to the quantity of pixels in the eleventh colorgroup, that is, a ratio of the quantity of pixels of the color N to thequantity of pixels in the target color group.

Finally, the target red channel value, the target green channel value,and the target blue channel value are combined into the targetthree-channel red-green-blue value (that is, these values are directlyused as the target three-channel red-green-blue value), and the targetthree-channel red-green-blue value is used as a three-channelred-green-blue value of the first dominant color.

For example, it is assumed that the target red channel value is 255,that the target green channel value is 100, and that the target bluechannel value is 50. The target red channel value 255, the target greenchannel value 100, and the target blue channel value 50 are combinedinto the target three-channel red-green-blue value (255, 100, 50), andthe target three-channel red-green-blue value (255, 100, 50) is used asthe three-channel red-green-blue value of the first dominant color. Inthis case, the three-channel red-green-blue value of the first dominantcolor is (255, 100, 50).

In FIG. 6, this embodiment of this application provides a method forgenerating the first dominant color. In the plurality of color groups,the target color group is the color group having the largest quantity ofpixels. Therefore, if the target color group includes at least twosimilar colors, the first dominant color generated based on all thecolors in the target color group can better reflect the main color inthe target image.

FIG. 10 is a schematic diagram of classification of color typesaccording to an embodiment of this application. This embodiment of thisapplication provides a plurality of color types. The following brieflydescribes the color types provided in this embodiment of thisapplication.

In FIG. 10, the color types include a polychromatic type A and amonochromatic type B. The polychromatic type A includes a polychromaticgrayscale type A-1 and a polychromatic non-grayscale type A-2. Thepolychromatic non-grayscale type A-2 includes a polychromatic lowsaturation type A-2-1 and a polychromatic general type A-2-2. Themonochromatic type B includes a monochromatic achromatic type B-1 and amonochromatic colorful type B-2.

The polychromatic type A is used to indicate that a ratio of a quantityof pixels corresponding to a first dominant color in a target image to aquantity of pixels corresponding to the target image is less than afirst threshold. The first threshold is a preset value. For example, thefirst threshold may be 90%. The polychromatic type is divided into thepolychromatic grayscale type A-1 and the polychromatic non-grayscaletype A-2 based on a ratio of a quantity of pixels corresponding tocolors having a same three-channel red-green-blue value in the targetimage to the quantity of pixels corresponding to the target image.

The polychromatic grayscale type A-1 is used to indicate that the ratioof the quantity of pixels corresponding to the first dominant color inthe target image to the quantity of pixels corresponding to the targetimage is less than the first threshold, and the ratio of the quantity ofpixels corresponding to the colors having the same three-channelred-green-blue value in the target image to the quantity of pixelscorresponding to the target image is greater than a second threshold.The second threshold is a preset value. For example, the secondthreshold may be 90%.

The polychromatic non-grayscale type A-2 is used to indicate that theratio of the quantity of pixels corresponding to the first dominantcolor in the target image to the quantity of pixels corresponding to thetarget image is less than the first threshold, and the ratio of thequantity of pixels corresponding to the colors having the samethree-channel red-green-blue value in the target image to the quantityof pixels corresponding to the target image is less than the secondthreshold. The second threshold is a preset value. For example, thesecond threshold may be 90%. The polychromatic non-grayscale type A-2includes the polychromatic low saturation type A-2-1 and thepolychromatic general type A-2-2.

The polychromatic low saturation type A-2-1 is used to indicate that theratio of the quantity of pixels corresponding to the first dominantcolor in the target image to the quantity of pixels corresponding to thetarget image is less than the first threshold, and the ratio of thequantity of pixels corresponding to the colors having the samethree-channel red-green-blue value in the target image to the quantityof pixels corresponding to the target image is less than the secondthreshold, and saturation of the first dominant color is less than athird threshold. The third threshold is a preset value. For example, thethird threshold may be 10%.

The polychromatic general type A-2-2 is used to indicate that the ratioof the quantity of pixels corresponding to the first dominant color inthe target image to the quantity of pixels corresponding to the targetimage is less than the first threshold, and the ratio of the quantity ofpixels corresponding to the colors having the same three-channelred-green-blue value in the target image to the quantity of pixelscorresponding to the target image is less than the second threshold, andthe saturation of the first dominant color is greater than the thirdthreshold.

The monochromatic type B is used to indicate that the ratio of thequantity of pixels corresponding to the first dominant color in thetarget image to the quantity of pixels corresponding to the target imageis greater than the first threshold. The monochromatic type B includesthe monochromatic achromatic type B-1 and the monochromatic colorfultype B-2.

The monochromatic achromatic type B-1 is used to indicate that the ratioof the quantity of pixels corresponding to the first dominant color inthe target image to the quantity of pixels corresponding to the targetimage is greater than the first threshold, and the saturation of thefirst dominant color is equal to 0.

The monochromatic colorful type B-2 is used to indicate that the ratioof the quantity of pixels corresponding to the first dominant color inthe target image to the quantity of pixels corresponding to the targetimage is greater than the first threshold, and the saturation of thefirst dominant color is greater than 0.

With reference to FIG. 6, after step S24, that is, after the terminalgenerates the first dominant color based on all the colors in the targetcolor group, the terminal may further generate more dominant colors, andmore dominant colors may provide a user with more options. More dominantcolors may be generated in a plurality of manners. The followingdescribes three manners of generating a second dominant color.

First manner: When the color type of the target image is thepolychromatic type, determine, in the plurality of color groups, aspecified color group having a second largest quantity of pixels, andgenerate the second dominant color based on all colors in the specifiedcolor group.

In the first manner, if the color type of the target image is thepolychromatic type, the terminal may find, in the plurality of colorgroups resulting from division, the specified color group having thesecond largest quantity of pixels. Finally, the second dominant color isgenerated based on all the colors in the specified color group. For theimplementation of generating the second dominant color based on all thecolors in the specified color group, refer to the implementation ofgenerating the first dominant color based on all the colors in thetarget color group in step S24.

For example, with reference to FIG. 9, when the color type of the targetimage is the polychromatic type, the terminal determines, in the eightcolor groups, the seventh color group having a second largest quantityof pixels, and then the terminal generates the second dominant colorbased on the color A, the color B, the color C, and the color D in theseventh color group.

Second manner: When the color type of the target image is themonochromatic colorful type, obtain a second dominant color adjustmentvalue corresponding to the monochromatic colorful type, and configure ahue of the first dominant color based on the second dominant coloradjustment value to generate the second dominant color.

In the second manner, if the color type of the target image is themonochromatic colorful type, the terminal obtains the second dominantcolor adjustment value corresponding to the monochromatic colorful type,and configures the hue of the first dominant color based on the seconddominant color adjustment value to generate the second dominant color.

For example, it is assumed that the first dominant color is red, and thehue of the first dominant color is 0 degrees, and saturation of thefirst dominant color is 100%, and brightness of the first dominant coloris 100%. When the color type of the target image is the monochromaticcolorful type, the terminal obtains the second dominant color adjustmentvalue corresponding to the monochromatic colorful type. Assuming thatthe second dominant color adjustment value corresponding to themonochromatic colorful type is to increase the hue of the first dominantcolor by 180 degrees, the terminal configures the hue of the firstdominant color based on the second dominant color adjustment value togenerate the second dominant color, where a hue of the obtained seconddominant color is 180 degrees, saturation of the second dominant coloris 100%, and brightness of the second dominant color is 100%. In thiscase, the second dominant color is light cyan.

Third manner: When the color type of the target image is themonochromatic achromatic type, obtain a second dominant color adjustmentvalue corresponding to the monochromatic achromatic type, and configurebrightness of the first dominant color based on the second dominantcolor adjustment value to generate the second dominant color.

In the third manner, if the color type of the target image is themonochromatic achromatic type, the terminal obtains the second dominantcolor adjustment value corresponding to the monochromatic achromatictype, and configures brightness of the first dominant color based on thesecond dominant color adjustment value to generate the second dominantcolor.

For example, assuming that the ratio of the quantity of pixels of thefirst dominant color of the target image in the target image to thequantity of pixels corresponding to the target image is greater than90%, and the saturation of the first dominant color is equal to 0, itindicates that the color type of the target image is the monochromaticachromatic type. Assuming that the first dominant color is black, andthe hue of the first dominant color is 0 degrees, and the saturation ofthe first dominant color is 0%, and the brightness of the first dominantcolor is 0%, when the color type of the target image is themonochromatic achromatic type, the terminal obtains the second dominantcolor adjustment value corresponding to the monochromatic achromatictype. Assuming that the second dominant color adjustment valuecorresponding to the monochromatic achromatic type is to increase thebrightness of the first dominant color by 20%, the terminal configuresthe hue of the first dominant color based on the second dominant coloradjustment value to generate the second dominant color, where a hue ofthe obtained the second dominant color is 0 degrees, saturation of thesecond dominant color is 0%, and brightness of the second dominant coloris 20%.

For another example, assuming that the ratio of the quantity of pixelsof the first dominant color of the target image in the target image tothe quantity of pixels corresponding to the target image is greater than90%, and the saturation of the first dominant color is equal to 0, itindicates that the color type of the target image is the monochromaticachromatic type. Assuming that the first dominant color is white, andthe hue of the first dominant color is 0 degrees, and the saturation ofthe first dominant color is 0%, and the brightness of the first dominantcolor is 100%, when the color type of the target image is themonochromatic achromatic type, the terminal obtains the second dominantcolor adjustment value corresponding to the monochromatic achromatictype. Assuming that the second dominant color adjustment valuecorresponding to the monochromatic achromatic type is to decrease thebrightness of the first dominant color by 20%, the terminal configuresthe hue of the first dominant color based on the second dominant coloradjustment value to generate the second dominant color, where a hue ofthe obtained the second dominant color is 0 degrees, saturation of thesecond dominant color is 0%, and brightness of the second dominant coloris 80%.

For another example, assuming that the ratio of the quantity of pixelsof the first dominant color of the target image in the target image tothe quantity of pixels corresponding to the target image is greater than90%, and the saturation of the first dominant color is equal to 0, itindicates that the color type of the target image is the monochromaticachromatic type. Assuming that the first dominant color is gray, and thehue of the first dominant color is 0 degrees, and the saturation of thefirst dominant color is 0%, and the brightness of the first dominantcolor is 50%, when the color type of the target image is themonochromatic achromatic type, the terminal obtains the second dominantcolor adjustment value corresponding to the monochromatic achromatictype. Assuming that the second dominant color adjustment valuecorresponding to the monochromatic achromatic type is to decrease thebrightness of the first dominant color by 25%, the terminal configuresthe hue of the first dominant color based on the second dominant coloradjustment value to generate the second dominant color, where a hue ofthe obtained the second dominant color is 0 degrees, saturation of thesecond dominant color is 0%, and brightness of the second dominant coloris 25%.

After the second dominant color is generated, a second auxiliary colormay be further generated based on a dominant color adjustment parameterand the second dominant color. Specifically, the terminal needs to firstobtain a dominant color adjustment parameter corresponding to the colortype of the target image, where the dominant color adjustment parameterincludes at least one of brightness and saturation; then the terminaladjusts the second dominant color based on the dominant color adjustmentparameter to generate a second bright auxiliary color and a second darkauxiliary color; and next, the terminal determines the second brightauxiliary color or the second dark auxiliary color as the secondauxiliary color, where the second auxiliary color is a color with a hueclose to that of the second dominant color but with a difference insaturation or brightness, and being close in hue means that an absolutevalue of hue difference between the second dominant color and the secondauxiliary color is less than a threshold. For example, the threshold maybe 30 degrees.

A specific process in which the terminal obtains the dominant coloradjustment parameter corresponding to the color type of the target imageis similar to step S41 in an embodiment shown in FIG. 12. Refer todetailed descriptions in step S41 in the embodiment shown in FIG. 12.That the terminal adjusts the second dominant color based on thedominant color adjustment parameter to generate a second brightauxiliary color and a second dark auxiliary color is similar to step S42in the embodiment shown in FIG. 12. Refer to detailed descriptions instep S42 in the embodiment shown in FIG. 12. That the terminaldetermines the second bright auxiliary color or the second darkauxiliary color as the second auxiliary color is similar to step S43 inthe embodiment shown in FIG. 12. Refer to detailed descriptions in stepS43 in the embodiment shown in FIG. 12.

After the terminal adjusts the second dominant color based on thedominant color adjustment parameter to generate the second auxiliarycolor, if the user wishes to set the second auxiliary color as a colorof a foreground element, the user may enter an instruction to theterminal. When the terminal receives the instruction entered by the userfor setting the second auxiliary color as the color of the foregroundelement, the terminal sets the second auxiliary color as the color ofthe foreground element. Therefore, more options can be provided for theuser.

After the terminal sets the second auxiliary color as the color of theforeground element, to better highlight the foreground element in thetarget image, the terminal may further add a background layer on abackground element, so that the background layer is located between thetarget image and the foreground element, where the background layer maybe a layer with unchanged transparency or a layer with gradienttransparency.

Because the background layer is located between the target image and theforeground element, the background layer may be used to set off theforeground element and further highlight the foreground element.Moreover, the hue of the second dominant color is close to the hue ofthe second auxiliary color, and there is good color fusion between acolor of the background layer and the color of the foreground element.In addition, because there is a difference between the second dominantcolor and the second auxiliary color in saturation or brightness, thereis also good contrast between the second dominant color and the secondauxiliary color, and there is good contrast between the color of thebackground layer and the color of the foreground element. Therefore,when the user browses the to-be-displayed interface, the user has strongimmersive experience.

With reference to FIG. 6, after step S23 and before step S24, the methodmay further include the following step: determining whether the colortype of the target image is the polychromatic grayscale type or thepolychromatic low saturation type; and when the color type of the targetimage is the polychromatic grayscale type or the polychromatic lowsaturation type, converting colors having different three-channelred-green-blue values in the target color group into colors having asame three-channel red-green-blue value, and then performing step S24;or when the color type of the target image is not the polychromaticgrayscale type or the polychromatic low saturation type, performing stepS24.

After step S23, that is, after the terminal determines, in the pluralityof color groups, the target color group having the largest quantity ofpixels, the terminal needs to determine whether the color type of thetarget image is the polychromatic grayscale type or the polychromaticlow saturation type. If the color type of the target image is thepolychromatic grayscale type, it indicates that the ratio of thequantity of pixels corresponding to the colors having the samethree-channel red-green-blue value in the target image to the quantityof pixels corresponding to the target image is greater than the secondthreshold, that is, colors of a majority of pixels in the target imageare black, white, or gray. To ensure that the generated first dominantcolor complies with a dominant tone of the target image, the terminalperforms decoloring processing on colored pixels in the target colorgroup, so that the colored pixels in the target color group areconverted into black, white, or gray.

Likewise, if the color type of the target image is the polychromatic lowsaturation type, it indicates that saturation of a majority of pixels inthe target image is low. Therefore, the target image is more likely tobe black, white, or gray. To ensure that the generated first dominantcolor complies with the dominant tone of the target image, the terminalperforms decoloring processing on the colored pixels in the target colorgroup, so that the colored pixels in the target color group areconverted into black, white, or gray.

The colors having different three-channel red-green-blue values in thetarget color group may be converted, in a plurality of manners, into thecolors having the same three-channel red-green-blue value, that is,there are a plurality of decoloring processing methods. The followingbriefly describes one manner.

For example, a decoloring processing formula=R*0.299+G*0.587+B*0.114 maybe used. It is assumed that 10 pixels exist in the target color group,where colors of nine of the 10 pixels are black, white, or gray, thatis, three-channel red-green-blue values of the nine pixels are the same,a color of one of the 10 pixels is red, and a three-channelred-green-blue value of the red target pixel is (255, 0, 0). When theterminal determines that the color type of the target image is thepolychromatic grayscale type or the polychromatic low saturation type,the terminal converts the colors having different three-channelred-green-blue values in the target color group into the colors havingthe same three-channel red-green-blue value. To be specific, by usingthe decoloring processing formula, the terminal converts the red targetpixel into a color having the same three-channel red-green-blue value.Specifically, because the three-channel red-green-blue value of the redtarget pixel is (255, 0, 0), that is, R=255, G=0, and B=0, decoloringprocessingformula=R*0.299+G*0.587+B*0.114=255*0.299+0*0.587+0*0.114=76.245 76, and76 is used as the three-channel red-green-blue value of the targetpixel, that is, the three-channel red-green-blue value of the targetpixel is (76, 76, 76). In this case, the target pixel is gray.

FIG. 11 is a flowchart of still another interface element color displaymethod according to an embodiment of this application. The embodimentshown in FIG. 11 is a specific implementation of step S121 in FIG. 2,that is, the embodiment shown in FIG. 11 is how to determine a firstdominant color of a target image. The method shown in FIG. 11 includesthe following steps.

Step S31: Obtain each color in a target image.

Step S32: Determine, among the colors in the target image, a first colorhaving a largest quantity of corresponding pixels.

Step S33: Determine the first color as a first dominant color.

In step S31 to step S33, after a terminal obtains a target imageincluded in a to-be-displayed interface, the terminal needs to firstobtain each color in the target image, so that the terminal determines,among the colors in the target image, a first color having a largestquantity of pixels and can finally use the first color as a firstdominant color.

For example, it is assumed that there are three colors in total in thetarget image, which are a color A, a color B, and a color Crespectively, where the color A in the target image has 200 pixels, thecolor B in the target image has 150 pixels, and the color C in thetarget image has 100 pixels. The terminal may determine, among the threecolors in the target image, that a color having a largest quantity ofcorresponding pixels is the color A. In this case, the terminaldetermines the color A as the first dominant color.

In the embodiment shown in FIG. 11, after step S33, that is, after thefirst color is determined as the first dominant color, the followingmanner may be further used to obtain a second dominant color: firstdetermining, among the colors in the target image, a second color havinga second largest quantity of corresponding pixels; and then determiningthe second color as the second dominant color.

For example, it is assumed that there are three colors in total in thetarget image, which are a color A, a color B, and a color Crespectively, where the color A in the target image has 200 pixels, thecolor B in the target image has 150 pixels, and the color C in thetarget image has 100 pixels. The terminal may determine, among the threecolors in the target image, that a color having a largest quantity ofcorresponding pixels is the color A, and the terminal may furtherdetermine, among the three colors in the target image, that a colorhaving a second largest quantity of corresponding pixels is the color B.In this case, the terminal determines the color B as the second dominantcolor.

FIG. 12 is a flowchart of still another interface element color displaymethod according to an embodiment of this application. The embodimentshown in FIG. 12 is a specific implementation of step S122 in FIG. 2,that is, the embodiment shown in FIG. 12 is how to determine a firstauxiliary color based on a color type. The method shown in FIG. 12includes the following steps.

Step S41: Obtain a dominant color adjustment parameter corresponding toa color type of a target image, where the dominant color adjustmentparameter includes at least one of brightness and saturation.

Different color types correspond to different dominant color adjustmentparameters. There are a plurality of cases of obtaining the dominantcolor adjustment parameter corresponding to the color type of the targetimage. The following describes two cases.

First case: When the color type of the target image is a polychromaticgeneral type or a monochromatic colorful type, obtain a first brightnessadjustment value, a second brightness adjustment value, a firstsaturation adjustment value, and a second saturation adjustment valuecorresponding to the polychromatic general type or the monochromaticcolorful type.

In the first case, the first brightness adjustment value and the secondbrightness adjustment value are separately used to adjust brightness ofa dominant color, the first saturation adjustment value and the secondsaturation adjustment value are separately used to adjust saturation ofthe dominant color, and the dominant color adjustment parameter includesthe first brightness adjustment value, the second brightness adjustmentvalue, the first saturation adjustment value, and the second saturationadjustment value.

For example, referring to Table 1 and FIG. 10, Table 1 shows a mappingrelationship between the color type and the dominant color adjustmentparameter. As can be learned from Table 1, if the color type is apolychromatic general type A-2-2 or a monochromatic colorful type B-2,the dominant color adjustment parameter corresponding to the color typeincludes the first brightness adjustment value, the second brightnessadjustment value, the first saturation adjustment value, and the secondsaturation adjustment value, where the first brightness adjustment valueis 1.0, the first saturation adjustment value is 0.2, the secondbrightness adjustment value is 0.2, and the second saturation adjustmentvalue is 1.0.

TABLE 1 Dominant color adjustment parameter First First Second Secondbrightness saturation brightness saturation adjustment adjustmentadjustment adjustment Color type value value value value Polychromatic1.0 0.2 0.2 1.0 general type A-2-2 Monochromatic colorful type B-2

Second case: When the color type of the target image is a polychromaticlow saturation type, a polychromatic grayscale type, or a monochromaticachromatic type, obtain a first brightness adjustment value and a secondbrightness adjustment value corresponding to the polychromatic lowsaturation type, the polychromatic grayscale type, or the monochromaticachromatic type.

In the second case, the first brightness adjustment value and the secondbrightness adjustment value are separately used to adjust brightness ofa dominant color, and the dominant color adjustment parameter includesthe first brightness adjustment value and the second brightnessadjustment value.

For example, referring to Table 2 and FIG. 10, Table 2 shows a mappingrelationship between the color type and the dominant color adjustmentparameter. As can be learned from Table 2, if the color type is apolychromatic low saturation type A-2-1, a polychromatic grayscale typeA-1, or a monochromatic achromatic type B-1, the dominant coloradjustment parameter corresponding to the color type includes the firstbrightness adjustment value and the second brightness adjustment value,where the first brightness adjustment value is 1.0, and the secondbrightness adjustment value is 0.2.

TABLE 2 Dominant color adjustment parameter First First Second Secondbrightness saturation brightness saturation adjustment adjustmentadjustment adjustment Color type value value value value Polychromaticlow 1.0 Null 0.2 Null saturation type A-2-1 Polychromatic grayscale typeA-1 Monochromatic achromatic type B-l

Step S42: Adjust a first dominant color based on the dominant coloradjustment parameter to generate a first bright auxiliary color and afirst dark auxiliary color.

When the color type of the target image is the polychromatic generaltype or the monochromatic colorful type, the terminal obtains the firstbrightness adjustment value, the second brightness adjustment value, thefirst saturation adjustment value, and the second saturation adjustmentvalue corresponding to the polychromatic general type or themonochromatic colorful type; and then the terminal adjusts brightnessand saturation of the first dominant color based on the first brightnessadjustment value and the first saturation adjustment value to generatethe first bright auxiliary color, and adjusts brightness and saturationof the first dominant color based on the second brightness adjustmentvalue and the second saturation adjustment value to generate the firstdark auxiliary color.

With reference to Table 1 and FIG. 10, for example, if the color type isthe polychromatic general type A-2-2 or the monochromatic colorful typeB-2, the dominant color adjustment parameter corresponding to the colortype includes the first brightness adjustment value, the secondbrightness adjustment value, the first saturation adjustment value, andthe second saturation adjustment value, where the first brightnessadjustment value is 1.0, the first saturation adjustment value is 0.2,the second brightness adjustment value is 0.2, and the second saturationadjustment value is 1.0. After the terminal obtains the four adjustmentvalues, the terminal adjusts brightness and saturation of the firstdominant color based on the first brightness adjustment value 1.0 andthe first saturation adjustment value 0.2 to generate the first brightauxiliary color, and adjusts brightness and saturation of the firstdominant color based on the second brightness adjustment value 0.2 andthe second saturation adjustment value 1.0 to generate the first darkauxiliary color, thereby obtaining two auxiliary colors.

When the color type of the target image is the polychromatic lowsaturation type, the polychromatic grayscale type, or the monochromaticachromatic type, the terminal obtains the first brightness adjustmentvalue and the second brightness adjustment value corresponding to thepolychromatic low saturation type, the polychromatic grayscale type, orthe monochromatic achromatic type; and then the terminal adjustsbrightness of the first dominant color based on the first brightnessadjustment value to generate the first bright auxiliary color, andadjusts brightness of the first dominant color based on the secondbrightness adjustment value to generate the first dark auxiliary color.

With reference to Table 2 and FIG. 10, for example, if the color type isthe polychromatic low saturation type A-2-1, the polychromatic grayscaletype A-1, or the monochromatic achromatic type B-1, the dominant coloradjustment parameter corresponding to the color type includes the firstbrightness adjustment value and the second brightness adjustment value,where the first brightness adjustment value is 1.0, and the secondbrightness adjustment value is 0.2. After the terminal obtains the twoadjustment values, the terminal adjusts brightness of the first dominantcolor based on the first brightness adjustment value 1.0 to generate thefirst bright auxiliary color, and adjusts brightness of the firstdominant color based on the second brightness adjustment value 0.2 togenerate the first dark auxiliary color, thereby obtaining two auxiliarycolors.

Step S43: Determine the first bright auxiliary color or the first darkauxiliary color as a first auxiliary color.

In step S43, the first bright auxiliary color or the first darkauxiliary color may be determined as the first auxiliary color in thefollowing manner: First, the terminal determines whether a ratio of abrightness differentiation parameter of the first dominant color to abrightness differentiation parameter of the first bright auxiliary coloris greater than a fourth threshold or less than a reciprocal of thefourth threshold; and when the ratio of the brightness differentiationparameter of the first dominant color to the brightness differentiationparameter of the first bright auxiliary color is greater than the fourththreshold or less than the reciprocal of the fourth threshold, theterminal determines the first bright auxiliary color as the firstauxiliary color; or when the ratio of the brightness differentiationparameter of the first dominant color to the brightness differentiationparameter of the first bright auxiliary color is less than the fourththreshold or greater than the reciprocal of the fourth threshold, theterminal determines the first dark auxiliary color as the firstauxiliary color.

The brightness differentiation parameter of the first bright auxiliarycolor is greater than a brightness differentiation parameter of thefirst dark auxiliary color, the brightness differentiation parameter ofthe first dominant color is obtained through calculation based on athree-channel red-green-blue value of the first dominant color, thebrightness differentiation parameter of the first bright auxiliary coloris obtained through calculation based on a three-channel red-green-bluevalue of the first bright auxiliary color, and the brightnessdifferentiation parameter of the first dark auxiliary color is obtainedthrough calculation based on a three-channel red-green-blue value of thefirst dark auxiliary color.

If the ratio of the brightness differentiation parameter of the firstdominant color to the brightness differentiation parameter of the firstbright auxiliary color is greater than the fourth threshold or less thanthe reciprocal of the fourth threshold, which indicates that contrastbetween the first dominant color and the first bright auxiliary color isappropriate, the terminal determines the first bright auxiliary color asthe first auxiliary color, so that there is good contrast between acolor of a foreground element and a color of the target image; or if theratio of the brightness differentiation parameter of the first dominantcolor to the brightness differentiation parameter of the first brightauxiliary color is less than the fourth threshold or greater than thereciprocal of the fourth threshold, which indicates that contrastbetween the first dominant color and the first bright auxiliary color isnot appropriate, the terminal determines the first dark auxiliary coloras the first auxiliary color, so that there is good contrast between acolor of a foreground element and a color of the target image.

A brightness differentiation parameter of a color may be obtained in aplurality of manners. The following describes a specific implementation.

Step 1: Obtain a three-channel red-green-blue value of a target color.

Step 2: Separately calculate ratios of a red channel value, a greenchannel value, and a blue channel value to 255.

Step 3: Determine whether the ratio of the red channel value to 255 isless than a target value; and if yes, obtain a target red channel valueby calculating the ratio of the three-channel red-green-blue value ofthe target color to 255 by using a first formula; or if no, obtain atarget red channel value by calculating the ratio of the three-channelred-green-blue value of the target color to 255 by using a secondformula.

For the green channel value of the target color and the blue channelvalue of the target color, a manner same as the manner of determiningand calculating the red channel value of the target color is used, andfurther, a target green channel value and a target blue channel valueare obtained.

Step 4: Obtain a brightness differentiation parameter of the targetcolor by calculating the target red channel value, the target greenchannel value, and the target blue channel value by using a thirdformula.

For example, it is assumed that the target value is 0.03928. First, theterminal obtains the three-channel red-green-blue value of the targetcolor, which is (255, 0, 0), that is, a red channel value R1 of thetarget color is 255, a green channel value G1 of the target color is 0,and a blue channel value B1 of the target color is 0. Then the terminalcalculates a ratio R2 of the red channel value R1 of the target color to255, where R2=255±255=1, a ratio G2 of the green channel value of thetarget color to 255, where G2=0±255=0, and a ratio B2 of the bluechannel value of the target color to 255, where B2=0±255=0. Next, theterminal determines whether R2 is less than the target value 0.03928.The terminal may learn, by determining, that R2 is greater than thetarget value 0.03928. In this case, the terminal calculates the targetred channel value R3 by using a formula ((R2+0.055)±1.055) 2.4, wherethrough calculation, R3=((R2+0.055)±1.055) 2.4=((1+0.055)±1.055) 2.4=1.The terminal further determines whether G2 is less than the target value0.03928. The terminal may learn, by determining, that G2 is less thanthe target value 0.03928. In this case, the terminal calculates thetarget green channel value G3 by using a formula G2±12.92, where throughcalculation, G3=G2±12.92=0±12.92=0. The terminal further determineswhether B2 is less than the target value 0.03928. The terminal maylearn, by determining, that B2 is less than the target value 0.03928. Inthis case, the terminal calculates the target blue channel value B3 byusing a formula B2±12.92, where through calculation,B3=B2±12.92=0±12.92=0. After the terminal obtains the target red channelvalue R3, the target green channel value G3, and the target blue channelvalue B3, the terminal obtains a brightness differentiation parameter Lof the target color by performing calculation on the target red channelvalue R3, the target green channel value G3, and the target blue channelvalue B3, where through calculation,L=0.2126×R3+0.7152×G3+0.0722×B3=0.2126×1+0.7152× 0+0.0722×0=1+0+0=1. Inthis case, the terminal obtains the brightness differentiation parameterL of the target color.

Certainly, a manner of calculating a brightness differentiationparameter of a color is not limited to the provided manner, and othermanners may also be used. The manner of calculating a brightnessdifferentiation parameter of a color may be used to separately calculatethe brightness differentiation parameter of the first dominant color,the brightness differentiation parameter of the first bright auxiliarycolor, and the brightness differentiation parameter of the first darkauxiliary color.

FIG. 13 is a flowchart of still another interface element color displaymethod according to an embodiment of this application. The method shownin FIG. 13 includes the following steps.

Step S51: Obtain a target image included in a to-be-displayed interface.

The to-be-displayed interface includes a background element, thebackground element includes the target image and a background layer, andthe target image is used as a background of the background layer.

For a specific manner of step S51, refer to detailed descriptions instep S11 shown in FIG. 2.

Step S52: Perform color updating processing on the to-be-displayedinterface.

After a terminal obtains a target image included in a to-be-displayedinterface, the terminal needs to first generate a first dominant colorbased on colors in the target image, and then the terminal sets thefirst dominant color as a color of a background layer, to complete colorupdating processing on the to-be-displayed interface. Performing colorupdating processing on the to-be-displayed interface by the terminal mayinclude step S521 and step S522.

Step S521: Generate a first dominant color based on colors in the targetimage.

The first dominant color is a main color in the target image.

For a specific manner of step S521, refer to detailed descriptions instep S121 shown in FIG. 2.

Step S522: Set the first dominant color as a color of the backgroundlayer.

The background layer may be a layer with unchanged transparency or alayer with gradient transparency.

Step S53: Output the to-be-displayed interface that has undergone thecolor updating processing to a display device for displaying.

In the embodiment shown in FIG. 13, the terminal sets the first dominantcolor as the color of the background layer, and the target image is usedas the background of the background layer. Because the first dominantcolor is the main color in the target image, there is good color fusionbetween the color of the background layer and the color of the targetimage.

For how to generate the first dominant color based on the color in thetarget image in the embodiment shown in FIG. 13, refer to the embodimentshown in FIG. 6 and the embodiment shown in FIG. 11.

FIG. 14 is a schematic diagram of a terminal according to an embodimentof this application. The terminal includes the following modules.

An obtaining module 1 is configured to obtain a target image included ina to-be-displayed interface, where the to-be-displayed interfaceincludes a foreground element and a background element, the backgroundelement is used as a background of the foreground element, and thebackground element includes the target image. For a detailedimplementation, refer to detailed descriptions corresponding to step S11in the method embodiment shown in FIG. 2.

An updating module 2 is configured to perform color updating processingon the to-be-displayed interface, including: determining a firstdominant color of the target image, determining a color type of thetarget image based on an area-based ratio of the first dominant color inthe target image, determining a first auxiliary color based on the colortype, and setting the first auxiliary color as a color of the foregroundelement, where the first dominant color is a main color in the targetimage, and the first auxiliary color is a color with a hue close to thatof the first dominant color but with a difference in saturation orbrightness. For a detailed implementation, refer to detaileddescriptions corresponding to step S12 in the method embodiment shown inFIG. 2.

A display output module 3 is configured to output the to-be-displayedinterface that has undergone the color updating processing to a displaydevice for displaying. For a detailed implementation, refer to detaileddescriptions corresponding to step S13 in the method embodiment shown inFIG. 2.

In a feasible embodiment, the updating module 2 is specificallyconfigured to: obtain a dominant color adjustment parametercorresponding to the color type of the target image, where the dominantcolor adjustment parameter includes at least one of brightness andsaturation; adjust the first dominant color based on the dominant coloradjustment parameter to generate a first bright auxiliary color and afirst dark auxiliary color; and determine the first bright auxiliarycolor or the first dark auxiliary color as the first auxiliary color.

In a feasible embodiment, the updating module 2 is specificallyconfigured to: when the color type of the target image is apolychromatic general type or a monochromatic colorful type, obtain afirst brightness adjustment value, a second brightness adjustment value,a first saturation adjustment value, and a second saturation adjustmentvalue corresponding to the polychromatic general type or themonochromatic colorful type, where the first brightness adjustment valueand the second brightness adjustment value are separately used to adjustbrightness of the first dominant color, the first saturation adjustmentvalue and the second saturation adjustment value are separately used toadjust saturation of the first dominant color, and the dominant coloradjustment parameter includes the first brightness adjustment value, thesecond brightness adjustment value, the first saturation adjustmentvalue, and the second saturation adjustment value; the polychromaticgeneral type is used to indicate that a ratio of a quantity of pixelscorresponding to the first dominant color in the target image to aquantity of pixels corresponding to the target image is less than afirst threshold, a ratio of a quantity of pixels corresponding to colorshaving a same three-channel red-green-blue value in the target image tothe quantity of pixels corresponding to the target image is less than asecond threshold, and the saturation of the first dominant color isgreater than a third threshold; and the monochromatic colorful type isused to indicate that the ratio of the quantity of pixels correspondingto the first dominant color in the target image to the quantity ofpixels corresponding to the target image is greater than the firstthreshold, and the saturation of the first dominant color is greaterthan 0.

In a feasible embodiment, the updating module 2 is specificallyconfigured to: when the color type of the target image is apolychromatic low saturation type, a polychromatic grayscale type, or amonochromatic achromatic type, obtain a first brightness adjustmentvalue and a second brightness adjustment value corresponding to thepolychromatic low saturation type, the polychromatic grayscale type, orthe monochromatic achromatic type, where the first brightness adjustmentvalue and the second brightness adjustment value are separately used toadjust brightness of the first dominant color, and the dominant coloradjustment parameter includes the first brightness adjustment value andthe second brightness adjustment value; the polychromatic low saturationtype is used to indicate that a ratio of a quantity of pixelscorresponding to the first dominant color in the target image to aquantity of pixels corresponding to the target image is less than afirst threshold, a ratio of a quantity of pixels corresponding to colorshaving a same three-channel red-green-blue value in the target image tothe quantity of pixels corresponding to the target image is less than asecond threshold, and saturation of the first dominant color is lessthan a third threshold; the polychromatic grayscale type is used toindicate that the ratio of the quantity of pixels corresponding to thefirst dominant color in the target image to the quantity of pixelscorresponding to the target image is less than the first threshold, andthe ratio of the quantity of pixels corresponding to the colors havingthe same three-channel red-green-blue value in the target image to thequantity of pixels corresponding to the target image is greater than thesecond threshold; and the monochromatic achromatic type is used toindicate that the ratio of the quantity of pixels corresponding to thefirst dominant color in the target image to the quantity of pixelscorresponding to the target image is greater than the first threshold,and the saturation of the first dominant color is equal to 0.

In a feasible embodiment, the updating module 2 is specificallyconfigured to adjust the brightness and saturation of the first dominantcolor based on the first brightness adjustment value and the firstsaturation adjustment value to generate the first bright auxiliarycolor, and adjust the brightness and saturation of the first dominantcolor based on the second brightness adjustment value and the secondsaturation adjustment value to generate the first dark auxiliary color.

In a feasible embodiment, the updating module 2 is specificallyconfigured to adjust the brightness of the first dominant color based onthe first brightness adjustment value to generate the first brightauxiliary color, and adjust the brightness of the first dominant colorbased on the second brightness adjustment value to generate the firstdark auxiliary color.

In a feasible embodiment, the updating module 2 is specificallyconfigured to: determine whether a ratio of a brightness differentiationparameter of the first dominant color to a brightness differentiationparameter of the first bright auxiliary color is greater than a fourththreshold or less than a reciprocal of the fourth threshold; and whenthe ratio of the brightness differentiation parameter of the firstdominant color to the brightness differentiation parameter of the firstbright auxiliary color is greater than the fourth threshold or less thanthe reciprocal of the fourth threshold, determine the first brightauxiliary color as the first auxiliary color; or when the ratio of thebrightness differentiation parameter of the first dominant color to thebrightness differentiation parameter of the first bright auxiliary coloris less than the fourth threshold or greater than the reciprocal of thefourth threshold, determine the first dark auxiliary color as the firstauxiliary color, where the brightness differentiation parameter of thefirst bright auxiliary color is greater than a brightnessdifferentiation parameter of the first dark auxiliary color, thebrightness differentiation parameter of the first dominant color isobtained through calculation based on a three-channel red-green-bluevalue of the first dominant color, the brightness differentiationparameter of the first bright auxiliary color is obtained throughcalculation based on a three-channel red-green-blue value of the firstbright auxiliary color, and the brightness differentiation parameter ofthe first dark auxiliary color is obtained through calculation based ona three-channel red-green-blue value of the first dark auxiliary color.

In a feasible embodiment, the updating module 2 is specificallyconfigured to: obtain each color in the target image; sort each color inthe target image in a preset arrangement order to obtain a color queue,where the preset arrangement order is a pre-generated arrangement orderof colors; divide the color queue into a plurality of color groups basedon a preset grouping method and a quantity of pixels of each color inthe target image, where each of the plurality of color groups includesat least one color; determine, in the plurality of color groups, atarget color group having a largest quantity of pixels; and generate thefirst dominant color based on all colors in the target color group.

In a feasible embodiment, the updating module 2 is specificallyconfigured to: obtain a three-channel red-green-blue value of each colorin the target color group, where the three-channel red-green-blue valueincludes a red channel value, a green channel value, and a blue channelvalue; calculate a target red channel value based on the red channelvalue of each color in the target color group and a ratio of a quantityof pixels of each color in the target color group to a quantity ofpixels in the target color group; calculate a target green channel valuebased on the green channel value of each color in the target color groupand the ratio of the quantity of pixels of each color in the targetcolor group to the quantity of pixels in the target color group;calculate a target blue channel value based on the blue channel value ofeach color in the target color group and the ratio of the quantity ofpixels of each color in the target color group to the quantity of pixelsin the target color group; and combine the target red channel value, thetarget green channel value, and the target blue channel value into atarget three-channel red-green-blue value to obtain the first dominantcolor.

In a feasible embodiment, the updating module 2 is further configuredto: when the color type of the target image is a polychromatic type,determine, in the plurality of color groups, a specified color grouphaving a second largest quantity of pixels, and generate a seconddominant color based on all colors in the specified color group, wherethe polychromatic type is used to indicate that a ratio of a quantity ofpixels corresponding to the first dominant color in the target image toa quantity of pixels corresponding to the target image is less than afirst threshold.

In a feasible embodiment, the updating module 2 is further configuredto: when the color type of the target image is a monochromatic colorfultype, obtain a second dominant color adjustment value corresponding tothe monochromatic colorful type, and configure the hue of the firstdominant color based on the second dominant color adjustment value togenerate a second dominant color, where the monochromatic colorful typeis used to indicate that a ratio of a quantity of pixels correspondingto the first dominant color in the target image to a quantity of pixelscorresponding to the target image is greater than a first threshold, andsaturation of the first dominant color is greater than 0.

In a feasible embodiment, the updating module 2 is further configuredto: when the color type of the target image is a monochromaticachromatic type, obtain a second dominant color adjustment valuecorresponding to the monochromatic achromatic type, and configurebrightness of the first dominant color based on the second dominantcolor adjustment value to generate a second dominant color, where themonochromatic achromatic type is used to indicate that a ratio of aquantity of pixels corresponding to the first dominant color in thetarget image to a quantity of pixels corresponding to the target imageis greater than a first threshold, and saturation of the first dominantcolor is equal to 0.

In a feasible embodiment, the updating module 2 is further configuredto: obtain a dominant color adjustment parameter corresponding to thecolor type of the target image, where the dominant color adjustmentparameter includes at least one of brightness and saturation; adjust thesecond dominant color based on the dominant color adjustment parameterto generate a second bright auxiliary color and a second dark auxiliarycolor; determine the second bright auxiliary color or the second darkauxiliary color as a second auxiliary color, where the second auxiliarycolor is a color with a hue close to that of the second dominant colorbut with a difference in saturation or brightness; when an instructionfor setting the second auxiliary color as the color of the foregroundelement is received, set the second auxiliary color as the color of theforeground element; and set the second dominant color as a color of abackground layer, where the background layer is a layer with unchangedtransparency or a layer with gradient transparency, the backgroundelement further includes the background layer, and the background layeris located between the target image and the foreground element.

In a feasible embodiment, the updating module 2 is further configured toset the first dominant color as a color of a background layer, where thebackground layer is a layer with unchanged transparency or a layer withgradient transparency.

In a feasible embodiment, the updating module 2 is further configuredto: obtain an image region by extending one side or a plurality of sidesof the target image, where the image region includes the first dominantcolor; and use the image region and the target image as an updatedtarget image.

FIG. 15 is a schematic diagram of a terminal according to an embodimentof this application. The terminal 15 includes a central processing unit151, an image processor 152, a bus 153, a memory 154, and a non-volatilememory (non-volatile memory, NVM) memory 155. The terminal 15 in FIG. 15is equivalent to the terminal 1 in FIG. 1. For detailed descriptionsabout the terminal 15 in FIG. 15, refer to detailed descriptions aboutthe terminal 1 in the embodiment corresponding to FIG. 1.

The terminal 15 shown in FIG. 15 may run the interface element colordisplay methods in the embodiments corresponding to FIG. 2, FIG. 6, FIG.11, FIG. 12, and FIG. 13. With reference to FIG. 2 and FIG. 15, thecentral processing unit 151 may obtain, from the non-volatile memory 155by using the a bus 153, a target image included in a to-be-displayedinterface, and store the target image in the memory 154 by using the bus153. Then the central processing unit 151 performs color updatingprocessing on the to-be-displayed interface. Finally, the imageprocessor 152 receives the to-be-displayed interface that has undergonethe color updating processing by the central processing unit 151, andoutputs the to-be-displayed interface that has undergone the colorupdating processing to a display device for displaying.

What is claimed is:
 1. An interface element color display method,wherein the method comprises: obtaining a target image comprised in ato-be-displayed interface, wherein the to-be-displayed interfacecomprises a foreground element and a background element, the backgroundelement is used as a background of the foreground element, and thebackground element comprises the target image; performing color updatingprocessing on the to-be-displayed interface, comprising: determining afirst dominant color of the target image, determining a color type ofthe target image based on an area-based ratio of the first dominantcolor in the target image, determining a first auxiliary color based onthe color type, and setting the first auxiliary color as a color of theforeground element, wherein the first dominant color is a main color inthe target image, and the first auxiliary color is a color with a hueclose to that of the first dominant color but with a difference insaturation or brightness; and outputting the to-be-displayed interfacethat has undergone the color updating processing to a display device fordisplaying; wherein the color type of the target image is apolychromatic general type or a monochromatic colorful type.
 2. Theinterface element color display method according to claim 1, wherein thedetermining a first auxiliary color based on the color type comprises:obtaining a dominant color adjustment parameter corresponding to thecolor type of the target image, wherein the dominant color adjustmentparameter comprises at least one of brightness or saturation; adjustingthe first dominant color based on the dominant color adjustmentparameter to generate a first bright auxiliary color and a first darkauxiliary color; and determining the first bright auxiliary color or thefirst dark auxiliary color as the first auxiliary color.
 3. Theinterface element color display method according to claim 2, wherein theobtaining a dominant color adjustment parameter corresponding to thecolor type of the target image comprises: obtaining a first brightnessadjustment value, a second brightness adjustment value, a firstsaturation adjustment value, and a second saturation adjustment valuecorresponding to the polychromatic general type or the monochromaticcolorful type, wherein the first brightness adjustment value and thesecond brightness adjustment value are separately used to adjustbrightness of the first dominant color, the first saturation adjustmentvalue and the second saturation adjustment value are separately used toadjust saturation of the first dominant color, and the dominant coloradjustment parameter comprises the first brightness adjustment value,the second brightness adjustment value, the first saturation adjustmentvalue, and the second saturation adjustment value; the polychromaticgeneral type is used to indicate that a ratio of a quantity of pixels ofthe first dominant color in the target image to a quantity of pixels inthe target image is less than a first threshold, a ratio of a quantityof pixels of colors having a same three-channel red-green-blue value inthe target image to the quantity of pixels in the target image is lessthan a second threshold, and the saturation of the first dominant coloris greater than a third threshold; and the monochromatic colorful typeis used to indicate that the ratio of the quantity of pixels of thefirst dominant color in the target image to the quantity of pixels inthe target image is greater than the first threshold, and the saturationof the first dominant color is greater than 0; or when the color type ofthe target image is a polychromatic low saturation type, a polychromaticgrayscale type, or a monochromatic achromatic type, obtaining a firstbrightness adjustment value and a second brightness adjustment valuecorresponding to the polychromatic low saturation type, thepolychromatic grayscale type, or the monochromatic achromatic type,wherein the first brightness adjustment value and the second brightnessadjustment value are separately used to adjust brightness of the firstdominant color, and the dominant color adjustment parameter comprisesthe first brightness adjustment value and the second brightnessadjustment value; the polychromatic low saturation type is used toindicate that a ratio of a quantity of pixels of the first dominantcolor in the target image to a quantity of pixels in the target image isless than a first threshold, a ratio of a quantity of pixels of colorshaving a same three-channel red-green-blue value in the target image tothe quantity of pixels in the target image is less than a secondthreshold, and saturation of the first dominant color is less than athird threshold; the polychromatic grayscale type is used to indicatethat the ratio of the quantity of pixels of the first dominant color inthe target image to the quantity of pixels in the target image is lessthan the first threshold, and the ratio of the quantity of pixels of thecolors having the same three-channel red-green-blue value in the targetimage to the quantity of pixels in the target image is greater than thesecond threshold; and the monochromatic achromatic type is used toindicate that the ratio of the quantity of pixels of the first dominantcolor in the target image to the quantity of pixels in the target imageis greater than the first threshold, and the saturation of the firstdominant color is equal to
 0. 4. The interface element color displaymethod according to claim 3, wherein the adjusting the first dominantcolor based on the dominant color adjustment parameter to generate afirst bright auxiliary color and a first dark auxiliary color comprises:adjusting the brightness and saturation of the first dominant colorbased on the first brightness adjustment value and the first saturationadjustment value to generate the first bright auxiliary color, andadjusting the brightness and saturation of the first dominant colorbased on the second brightness adjustment value and the secondsaturation adjustment value to generate the first dark auxiliary color;or adjusting the brightness of the first dominant color based on thefirst brightness adjustment value to generate the first bright auxiliarycolor, and adjusting the brightness of the first dominant color based onthe second brightness adjustment value to generate the first darkauxiliary color.
 5. The interface element color display method accordingto claim 4, wherein the determining the first bright auxiliary color orthe first dark auxiliary color as the first auxiliary color comprises:determining whether a ratio of a brightness differentiation parameter ofthe first dominant color to a brightness differentiation parameter ofthe first bright auxiliary color is greater than a fourth threshold orless than a reciprocal of the fourth threshold; and when the ratio ofthe brightness differentiation parameter of the first dominant color tothe brightness differentiation parameter of the first bright auxiliarycolor is greater than the fourth threshold or less than the reciprocalof the fourth threshold, determining the first bright auxiliary color asthe first auxiliary color; or when the ratio of the brightnessdifferentiation parameter of the first dominant color to the brightnessdifferentiation parameter of the first bright auxiliary color is lessthan the fourth threshold or greater than the reciprocal of the fourththreshold, determining the first dark auxiliary color as the firstauxiliary color.
 6. The interface element color display method accordingto claim 1, wherein the determining a first dominant color of the targetimage comprises: obtaining each color in the target image; sorting eachcolor in the target image in a preset arrangement order to obtain acolor queue, wherein the preset arrangement order is a pre-generatedarrangement order of colors; dividing the color queue into a pluralityof color groups based on a preset grouping method and a quantity ofpixels of each color in the target image, wherein each of the pluralityof color groups comprises at least one color; determining, in theplurality of color groups, a target color group having a largestquantity of pixels; and generating the first dominant color based on allcolors in the target color group.
 7. The interface element color displaymethod according to claim 6, wherein the generating the first dominantcolor based on all colors in the target color group comprises: obtaininga three-channel red-green-blue value of each color in the target colorgroup, wherein the three-channel red-green-blue value comprises a redchannel value, a green channel value, and a blue channel value;calculating a target red channel value based on the red channel value ofeach color in the target color group and a ratio of a quantity of pixelsof each color in the target color group to a quantity of pixels in thetarget color group; calculating a target green channel value based onthe green channel value of each color in the target color group and theratio of the quantity of pixels of each color in the target color groupto the quantity of pixels in the target color group; calculating atarget blue channel value based on the blue channel value of each colorin the target color group and the ratio of the quantity of pixels ofeach color in the target color group to the quantity of pixels in thetarget color group; and combining the target red channel value, thetarget green channel value, and the target blue channel value into atarget three-channel red-green-blue value to obtain the first dominantcolor.
 8. The interface element color display method according to claim6, wherein after the determining a color type of the target image basedon an area-based ratio of the first dominant color in the target image,the method further comprises: when the color type of the target image isa polychromatic type, determining, in the plurality of color groups, aspecified color group having a second largest quantity of pixels, andgenerating a second dominant color based on all colors in the specifiedcolor group, wherein the polychromatic type is used to indicate that aratio of a quantity of pixels of the first dominant color in the targetimage to a quantity of pixels in the target image is less than a firstthreshold; or when the color type of the target image is a monochromaticcolorful type, obtaining a second dominant color adjustment valuecorresponding to the monochromatic colorful type, and configuring thehue of the first dominant color based on the second dominant coloradjustment value to generate a second dominant color, wherein themonochromatic colorful type is used to indicate that a ratio of aquantity of pixels of the first dominant color in the target image to aquantity of pixels in the target image is greater than a firstthreshold, and saturation of the first dominant color is greater than 0;or when the color type of the target image is a monochromatic achromatictype, obtaining a second dominant color adjustment value correspondingto the monochromatic achromatic type, and configuring brightness of thefirst dominant color based on the second dominant color adjustment valueto generate a second dominant color, wherein the monochromaticachromatic type is used to indicate that a ratio of a quantity of pixelsof the first dominant color in the target image to a quantity of pixelsin the target image is greater than the first threshold, and saturationof the first dominant color is equal to
 0. 9. The interface elementcolor display method according to claim 8, wherein after the seconddominant color is generated, the method further comprises: obtaining adominant color adjustment parameter corresponding to the color type ofthe target image, wherein the dominant color adjustment parametercomprises at least one of brightness and saturation; adjusting thesecond dominant color based on the dominant color adjustment parameterto generate a second bright auxiliary color and a second dark auxiliarycolor; determining the second bright auxiliary color or the second darkauxiliary color as a second auxiliary color, wherein the secondauxiliary color is a color with a hue close to that of the seconddominant color but with a difference in saturation or brightness; whenan instruction for setting the second auxiliary color as the color ofthe foreground element is received, setting the second auxiliary coloras the color of the foreground element; and setting the second dominantcolor as a color of a background layer, wherein the background layer isa layer with unchanged transparency or a layer with gradienttransparency, the background element further comprises the backgroundlayer, and the background layer is located between the target image andthe foreground element.
 10. The interface element color display methodaccording to claim 1, wherein the background element further comprises abackground layer, the background layer is located between the targetimage and the foreground element, and the performing color updatingprocessing on the target image further comprises: setting the firstdominant color as a color of the background layer, wherein thebackground layer is a layer with unchanged transparency or a layer withgradient transparency.
 11. The interface element color display methodaccording to claim 1, wherein after the determining a first dominantcolor of the target image, and before the outputting the to-be-displayedinterface that has undergone the color updating processing to a displaydevice for displaying, the method further comprises: obtaining an imageregion by extending one side or a plurality of sides of the targetimage, wherein the image region comprises the first dominant color; andusing the image region and the target image as an updated target image.12. A terminal, comprising: a memory configured to storing instructions;one or more processors configured to perform the instructions cause theterminal to: obtain a target image comprised in a to-be-displayedinterface, wherein the to-be-displayed interface comprises a foregroundelement and a background element, the background element is used as abackground of the foreground element, and the background elementcomprises the target image; perform color updating processing on theto-be-displayed interface, comprising: determining a first dominantcolor of the target image, determining a color type of the target imagebased on an area-based ratio of the first dominant color in the targetimage, determining a first auxiliary color based on the color type, andsetting the first auxiliary color as a color of the foreground element,wherein the first dominant color is a main color in the target image,and the first auxiliary color is a color with a hue close to that of thefirst dominant color but with a difference in saturation or brightness;and output the to-be-displayed interface that has undergone the colorupdating processing to a display device for displaying; wherein thecolor type of the target image is a polychromatic general type or amonochromatic colorful type.
 13. The terminal according to claim 12,wherein the one or more processors perform the instructions furthercause the terminal to: obtain a dominant color adjustment parametercorresponding to the color type of the target image, wherein thedominant color adjustment parameter comprises at least one of brightnessor saturation; adjust the first dominant color based on the dominantcolor adjustment parameter to generate a first bright auxiliary colorand a first dark auxiliary color; and determine the first brightauxiliary color or the first dark auxiliary color as the first auxiliarycolor.
 14. The terminal according to claim 13, wherein the one or moreprocessors perform the instructions further cause the terminal to:obtain a first brightness adjustment value, a second brightnessadjustment value, a first saturation adjustment value, and a secondsaturation adjustment value corresponding to the polychromatic generaltype or the monochromatic colorful type, wherein the first brightnessadjustment value and the second brightness adjustment value areseparately used to adjust brightness of the first dominant color, thefirst saturation adjustment value and the second saturation adjustmentvalue are separately used to adjust saturation of the first dominantcolor, and the dominant color adjustment parameter comprises the firstbrightness adjustment value, the second brightness adjustment value, thefirst saturation adjustment value, and the second saturation adjustmentvalue; the polychromatic general type is used to indicate that a ratioof a quantity of pixels of the first dominant color in the target imageto a quantity of pixels in the target image is less than a firstthreshold, a ratio of a quantity of pixels of colors having a samethree-channel red-green-blue value in the target image to the quantityof pixels in the target image is less than a second threshold, and thesaturation of the first dominant color is greater than a thirdthreshold; and the monochromatic colorful type is used to indicate thatthe ratio of the quantity of pixels of the first dominant color in thetarget image to the quantity of pixels in the target image is greaterthan the first threshold, and the saturation of the first dominant coloris greater than 0; or when the color type of the target image is apolychromatic low saturation type, a polychromatic grayscale type, or amonochromatic achromatic type, obtain a first brightness adjustmentvalue and a second brightness adjustment value corresponding to thepolychromatic low saturation type, the polychromatic grayscale type, orthe monochromatic achromatic type, wherein the first brightnessadjustment value and the second brightness adjustment value areseparately used to adjust brightness of the first dominant color, andthe dominant color adjustment parameter comprises the first brightnessadjustment value and the second brightness adjustment value; thepolychromatic low saturation type is used to indicate that a ratio of aquantity of pixels of the first dominant color in the target image to aquantity of pixels in the target image is less than a first threshold, aratio of a quantity of pixels of colors having a same three-channelred-green-blue value in the target image to the quantity of pixels inthe target image is less than a second threshold, and saturation of thefirst dominant color is less than a third threshold; the polychromaticgrayscale type is used to indicate that the ratio of the quantity ofpixels of the first dominant color in the target image to the quantityof pixels in the target image is less than the first threshold, and theratio of the quantity of pixels of the colors having the samethree-channel red-green-blue value in the target image to the quantityof pixels in the target image is greater than the second threshold; andthe monochromatic achromatic type is used to indicate that the ratio ofthe quantity of pixels of the first dominant color in the target imageto the quantity of pixels in the target image is greater than the firstthreshold, and the saturation of the first dominant color is equal to 0.15. The terminal according to claim 14, wherein the one or moreprocessors perform the instructions further cause the terminal to:adjust the brightness and saturation of the first dominant color basedon the first brightness adjustment value and the first saturationadjustment value to generate the first bright auxiliary color, andadjusting the brightness and saturation of the first dominant colorbased on the second brightness adjustment value and the secondsaturation adjustment value to generate the first dark auxiliary color;or adjust the brightness of the first dominant color based on the firstbrightness adjustment value to generate the first bright auxiliarycolor, and adjusting the brightness of the first dominant color based onthe second brightness adjustment value to generate the first darkauxiliary color.
 16. The terminal according to claim 15, wherein the oneor more processors perform the instructions further cause the terminalto: determine whether a ratio of a brightness differentiation parameterof the first dominant color to a brightness differentiation parameter ofthe first bright auxiliary color is greater than a fourth threshold orless than a reciprocal of the fourth threshold; and when the ratio ofthe brightness differentiation parameter of the first dominant color tothe brightness differentiation parameter of the first bright auxiliarycolor is greater than the fourth threshold or less than the reciprocalof the fourth threshold, determine the first bright auxiliary color asthe first auxiliary color; or when the ratio of the brightnessdifferentiation parameter of the first dominant color to the brightnessdifferentiation parameter of the first bright auxiliary color is lessthan the fourth threshold or greater than the reciprocal of the fourththreshold, determine the first dark auxiliary color as the firstauxiliary color.
 17. The terminal according to claim 12, wherein the oneor more processors perform the instructions further cause the terminalto: obtain each color in the target image; sort each color in the targetimage in a preset arrangement order to obtain a color queue, wherein thepreset arrangement order is a pre-generated arrangement order of colors;divide the color queue into a plurality of color groups based on apreset grouping method and a quantity of pixels of each color in thetarget image, wherein each of the plurality of color groups comprises atleast one color; determine, in the plurality of color groups, a targetcolor group having a largest quantity of pixels; and generate the firstdominant color based on all colors in the target color group.
 18. Theterminal according to claim 17, wherein the one or more processorsperform the instructions further cause the terminal to: obtain athree-channel red-green-blue value of each color in the target colorgroup, wherein the three-channel red-green-blue value comprises a redchannel value, a green channel value, and a blue channel value;calculate a target red channel value based on the red channel value ofeach color in the target color group and a ratio of a quantity of pixelsof each color in the target color group to a quantity of pixels in thetarget color group; calculate a target green channel value based on thegreen channel value of each color in the target color group and theratio of the quantity of pixels of each color in the target color groupto the quantity of pixels in the target color group; calculate a targetblue channel value based on the blue channel value of each color in thetarget color group and the ratio of the quantity of pixels of each colorin the target color group to the quantity of pixels in the target colorgroup; and combine the target red channel value, the target greenchannel value, and the target blue channel value into a targetthree-channel red-green-blue value to obtain the first dominant color.19. The terminal according to claim 17, wherein the one or moreprocessors perform the instructions further cause the terminal to: whenthe color type of the target image is a polychromatic type, determine,in the plurality of color groups, a specified color group having asecond largest quantity of pixels, and generate a second dominant colorbased on all colors in the specified color group, wherein thepolychromatic type is used to indicate that a ratio of a quantity ofpixels of the first dominant color in the target image to a quantity ofpixels in the target image is less than a first threshold; or when thecolor type of the target image is a monochromatic colorful type, obtaina second dominant color adjustment value corresponding to themonochromatic colorful type, and configure the hue of the first dominantcolor based on the second dominant color adjustment value to generate asecond dominant color, wherein the monochromatic colorful type is usedto indicate that a ratio of a quantity of pixels of the first dominantcolor in the target image to a quantity of pixels in the target image isgreater than a first threshold, and saturation of the first dominantcolor is greater than 0; or when the color type of the target image is amonochromatic achromatic type, obtain a second dominant color adjustmentvalue corresponding to the monochromatic achromatic type, and configurebrightness of the first dominant color based on the second dominantcolor adjustment value to generate a second dominant color, wherein themonochromatic achromatic type is used to indicate that a ratio of aquantity of pixels of the first dominant color in the target image to aquantity of pixels in the target image is greater than the firstthreshold, and saturation of the first dominant color is equal to
 0. 20.A non-volatile computer-readable storage medium, comprising instructionswhen performed by one or more processors in a computer cause thecomputer to: obtain a target image comprised in a to-be-displayedinterface, wherein the to-be-displayed interface comprises a foregroundelement and a background element, the background element is used as abackground of the foreground element, and the background elementcomprises the target image; perform color updating processing on theto-be-displayed interface, comprising: determining a first dominantcolor of the target image, determining a color type of the target imagebased on an area-based ratio of the first dominant color in the targetimage, determining a first auxiliary color based on the color type, andsetting the first auxiliary color as a color of the foreground element,wherein the first dominant color is a main color in the target image,and the first auxiliary color is a color with a hue close to that of thefirst dominant color but with a difference in saturation or brightness;and output the to-be-displayed interface that has undergone the colorupdating processing to a display device for displaying.